April 18, 200422 yr here's the deal:i am trying to get a RunOnce command into the registry which calls a bat in my OEM share. this works just fine when i specify the drive letter, but it refuses to accept %systemdrive% in the place of C: (or D: or whatever drive). is there an alternate syntax for this? i have a work-around but it's not that great so i figured i'd ask...
April 18, 200422 yr environment variables won't work in .reg files. REG ADD does.REG ADD /? from the Command Prompt
April 18, 200422 yr To use environment variables it has to be a REG_EXPAND_SZ keyREG ADD /? will show you as Aaron pointed out and it support's the REG_EXPAND also REG ADD HKLM\Software\MyCo /v Path /t REG_EXPAND_SZ /d %%systemroot%% Adds a value (name: Path, type: REG_EXPAND_SZ, data: %systemroot%) Notice: Use the double percentage ( %% ) inside the expand string
April 19, 200422 yr my way of doing it might be slightly easier, maybe (for me it is, I know nothing about registry editing)...I have a batch file something like this:@echo offif %systemdrive% == C: goto :c_driveif %systemdrive% == D: goto _drivegoto :error:c_drivereg /import %systemdrive%\install\imports\c-drive.reggoto :end_drivereg /import %systemdrive%\install\imports\d-drive.reggoto :end:errorecho Silly drive letters like %systemdrive% not supported!:endso as you can see, I have a similar need as you do of adding entries to the registry that will obviously not be the same if the drive assignment for %systemdrive% is different.... I just have different copies of the registry files that point to different drive letters like above...I hope this helps a little
April 19, 200422 yr hmm.. i just thought of an easier way@echo offreg /import %systemdrive%-drive.reg
April 21, 200422 yr Author that doesn't work.this is because %systemdrive% resolves to a drive letter followed by a colon. you cannot have a colon in a filename, so the bat points at a file which doesn't exist, and then your reg file is not imported...
April 21, 200422 yr %24% equals %systemdrive% in an inf file.See gosh excellent site for more info:http://gosh.msfnhosting.com/using_runonceex.htmI struggled to get the %systemroot% to work here, and the solution was to change the reg file to an inf file...Hope this helpsToBe Edited April 21, 200422 yr by ToBe
April 21, 200422 yr Crusher,Apr 18 2004, 09:22 PM]hmm.. i just thought of an easier way@echo offreg /import %systemdrive%-drive.regThis will work:reg /import %systemdrive:~0,1%-drive.regSyntax (see set /?):%variable:~[+-]offset,[+-]# of characters%
Create an account or sign in to comment