Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account



Photo

Win98 registry key with variables?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
16 replies to this topic

#1
Fonceur

Fonceur

    Newbie

  • Member
  • 31 posts
  • Joined 10-June 04
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"



How to remove advertisement from MSFN

#2
kukris

kukris

    Member

  • Member
  • PipPip
  • 112 posts
  • Joined 28-November 03
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


#3
nil

nil

    Junior

  • Member
  • Pip
  • 62 posts
  • Joined 09-December 04
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.)

#4
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,059 posts
  • Joined 13-October 04
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


#5
nil

nil

    Junior

  • Member
  • Pip
  • 62 posts
  • Joined 09-December 04
Is 'reg' an ME command Yzöwl, can't seem to find it on Win98SE.

#6
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,059 posts
  • Joined 13-October 04
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%

#7
Fonceur

Fonceur

    Newbie

  • Member
  • 31 posts
  • Joined 10-June 04
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... ;)

#8
nil

nil

    Junior

  • Member
  • Pip
  • 62 posts
  • Joined 09-December 04
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.robvander...hortcutinf.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.

#9
jelev

jelev
  • Member
  • 5 posts
  • Joined 27-November 04

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

hmm

#10
nil

nil

    Junior

  • Member
  • Pip
  • 62 posts
  • Joined 09-December 04
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. :)

#11
Fonceur

Fonceur

    Newbie

  • Member
  • 31 posts
  • Joined 10-June 04
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"
...


#12
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,059 posts
  • Joined 13-October 04
Just use the line I gave earlier

i.e. replace @ with ""

#13
Fonceur

Fonceur

    Newbie

  • Member
  • 31 posts
  • Joined 10-June 04

Just use the line I gave earlier

i.e. replace @ with ""

Except that /v, /d and /f are not valid options with the REG ADD from the Win98 resource kit and result in a too many command-line parameters error...

#14
chon_

chon_

    Member

  • Member
  • PipPip
  • 175 posts
  • Joined 04-September 03
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?
Hope it helps.

#15
jaclaz

jaclaz

    The Finder

  • Developer
  • 15,209 posts
  • Joined 23-July 04
Already posted a few times, but won't this do?

Nirsoft
http://www.nirsoft.n...ls/nircmd2.html


jaclaz

#16
nil

nil

    Junior

  • Member
  • Pip
  • 62 posts
  • Joined 09-December 04
Fonceur, in case you're still considering the inf approach, I've edited the list of the DIRID values I posted previously to add several values between 50 and 100 that I missed (my tests were done on a Win98SE system with no printer installed) along with some others that are listed in http://gosh.msfnhosting.com/infs.htm and the MSDN article "Using Dirids" (and I corrected the reference for dirid 1 - I'd erroneously listed it as Desktop but it actually refers to the directory from which the INF file was installed). I double-checked the dirids that weren't listed in the docs above and they're still good on my system - it'd be great if someone else could check those values, esp. on non-Win98SE systems.

The linked file above is well worth a read, and while it seems predominantly XP orientated there's *MUCH* more regarding inf files to be found on the 'Unattended Windows Discussion & Support' board on this site http://www.msfn.org/...hp?showforum=70.

#17
Fonceur

Fonceur

    Newbie

  • Member
  • 31 posts
  • Joined 10-June 04
Thanks for the links and infos!

For now I've paused a bit the work on that W98 CD as I managed to get something close enough to what I wanted with batch files and I used it on 2 persons' PC successfully. I have to admit that my enthusiasm droped after my installation went from 20 to 30 minutes moving some stuff (like .NET framework installation) from batch files to runonce... ;)