Jump to content

Win98 registry key with variables?


Fonceur

Recommended Posts

I am trying to make my Windows 98 unattended CD as generic as possible, so I was wondering if there is any way to use some variables in a .reg file... Basically, I would like to replace:

REGEDIT4
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\zz100]
"1"="C:\\windows\\Install\\netfx.msi /QB"
@="Dot NET Framework v1.1"

with something using a variable like %windir%:

REGEDIT4
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\zz130]
"1"="%windir%\Install\\netfx.msi /QB"
@="Dot NET Framework v1.1"

Link to comment
Share on other sites


As far as I know %windir% is the only variable that can be used, though I don't know if that works in reg files, but it works in batch files.

An other method is to use inf-files. They have code numbers for various Windows folders, like 10 for the Windows folder. I use this to copy files to Windows folders via msbatch.inf like:

[Install]
CopyFiles=winfile.copy, winsysfile.copy, inffile.copy, IOSubSysfile.copy, vmm32file.copy, rootfile.copy

[winfile.copy]
Editor2.exe

[vmm32file.copy]
Ios.vxd

[DestinationDirs]
winfile.copy=10
winsysfile.copy=11
inffile.copy=17
IOSubSysfile.copy=12
vmm32file.copy=22
rootfile.copy=30

Link to comment
Share on other sites

I tested the following

[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Fault]

"LogFile"="%windir%\\temp\\FAULTLOG.TXT"

and the resulting string was "%windir%\temp\FAULTLOG.TXT". The system seemed to treat %windir% as a literal directory name instead of expanding the variable when it was needed in this case (I forced a fault and it wasn't recorded) though other programs may treat it differently when it's called (I didn't test msi).

The hassle with trying to build and run a reg file using %windir% within a batch file, e.g.

>tmp.reg echo REGEDIT4

>>tmp.reg echo.

>>tmp.reg echo [HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Fault]

>>tmp.reg echo "LogFile"="%windir%\\FAULTLOG.TXT"

>>tmp.reg echo.

regedit /s tmp.reg

del tmp.reg

is the difficulty in adding an extra \ to the %windir% path (e.g., c:\\Windows), which regedit seems to want (when I tried the above the previous registry entry was not modified, nor was it recreated after deleting the entry). I've got no idea how you'd go about adding the extra seperator. (You could use a third-party search/replace command but then you may as well just edit the original reg file directly.)

Link to comment
Share on other sites

What about just adding two lines like this to your batch file:

reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\zz100 /v 1 /d "%windir%\Install\netfx.msi /QB" /f
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\zz100 /v "" /d "Dot NET Framework v1.1" /f

Link to comment
Share on other sites

My mistake, it may be in the Windows 98 Resource Kit

[EDIT]Why not try an inf instead:

[Version]
Signature=$CHICAGO$

[DefaultInstall]
AddReg = Reg.Settings

[Reg.Settings]
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\zz100",,0,"Dot NET Framework v1.1"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\zz100","1",0,"%10%\Install\netfx.msi /QB"

[/EDIT]

Also are you sure that the install directory is in C:\Windows and not just C:, for C: you would use %11% instead of %10%

Link to comment
Share on other sites

Thanks for the various suggestions.

Too bad that the REG /ADD function is not defined in Win98, I use it in Win XP and it makes all those things much easier.

I did consider using the ECHO >> trick, but that seems a bit messy if I want to add alot of entries that way.

So it looks as if using some .inf files will be the easiest way to do what I want. Is there a complete list of the LDID (%10% and such) somewhere? There is a partial list at the online Microsoft Windows 98 Resource Kit (appendix C), but for example there is no mention of the startup folder...

And yes I do put my install folder inside %windir%, makes it easier in batch file since I don't have to use tricks to determine the partition of that folder... ;)

Link to comment
Share on other sites

Too true Fonceur. In theory you can add an extra seperator using plain DOS but it takes the batch file from messy to ridiculous.

Here's a partial list of inf "dirid" values I've just build up after reading "Creating shortcuts using INF files" by Daniel U. Thibault (http://www.robvanderwoude.com/shortcutinf.html). I presume they are constant values. I couldn't be bother testing beyond 100... let me know if you find anything new, or a link to a more complete list.

[edited 16 Jan 05]

; 1=SourceDrive:\pathname of the directory from which the INF file was installed

; 2=c:\WININST0.400

; 3=c:\UNINSTAL.000

; 4=c:\UNINSTAL.000

; 5=inf

; 10=windows

; 11=system (or system32 on Windows NT)

; 12=system\iosubsystem

; 13=command

; 17=inf

; 18=help

; 19=windows

; 20=fonts

; 21=system\viewers

; 22=VMM32

; 23=color

; 24=c: (the Applications folder [ie. Program Files] root)

; 25=windows (MS doc refers to this as the "Shared directory". ?)

; 27=c:

; 28=windows

; 30=c: Root directory of the boot disk (might not be the same directory as dirid24)

; 31=c: (as above?)

; 32=c:\Winboot

; 33=start menu\programs

; 50 System directory (%windir%\system) on NT-based OS (only)

; 51 Spool directory (not used for installing printer drivers)

; 52 Spool drivers directory (not used for installing printer drivers)

; 53 User profile directory

; 54 Directory where ntldr.exe and osloader.exe are located (NT-based systems only)

; 55 Print processors directory (not used for installing printer drivers)

; Value Shell Special Folder

;

; 16406 All Users\Start Menu

; 16407 All Users\Start Menu\Programs

; 16408 All Users\Start Menu\Programs\Startup

; 16409 All Users\Desktop

; 16415 All Users\Favorites

; 16419 All Users\Application Data

; 16422 Program Files

; 16427 Program Files\Common

; 16429 All Users\Templates

; 16430 All Users\Documents

The author of the doc above adds this -

"%24% is the Applications (Program Files) directory root (typically C:\).

The entire %24%\Progra~1\Access~1\ path can be retrieved as %28710% under Win 98 and later."

Thanks Yzöwl, just downloaded reg.exe from the Resource Kit. (Dialup, only 100 odd hours to go...) Looks neat.

Link to comment
Share on other sites

Well spotted jelev but I'm not sure that's the problem, eg

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Runonce]

@="c:\\Windows\\desktop\\tst.bat"

works fine (Win 98SE) but not:

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Runonce]

@="%windir%\\desktop\\tst.bat"

%windir% doesn't seem to get expanded either by regedit or the OS when it reads it.

[Edit]

A sidenote some might find interesting - "%windir%" appears to be a valid directory name so the above would run "c:\%windir%\desktop\tst.bat" if it existed... Useless but true. :)

Link to comment
Share on other sites

I decided to try again the REG ADD route, so I got the REG.EXE file from the Win98 Resource kit. It does not quite have the same functionality as the Win XP version, but it is close enough.

I can't seem to modify the (Default) value with REG ADD, which should be something like @... So I guess I will need to also load a normal registry file with all the name of the programs/patches I want to install. At least the REG ADD takes care of the %windir% variable, so that's the important part.

REGEDIT4
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\zz100]
@="Dot NET Framework v1.1"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\zz110]
@="directX 9c"
...

Link to comment
Share on other sites

  • 3 weeks later...

Did you manage to change the @= key with REG.EXE? I can't find how to do it in w2k & xp you can do it with the /V /VE switches, but I don't know how to do it in win98. Anyone?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...