Sleepy P Posted April 18, 2004 Share Posted April 18, 2004 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... Link to comment Share on other sites More sharing options...
Aaron Posted April 18, 2004 Share Posted April 18, 2004 environment variables won't work in .reg files. REG ADD does.REG ADD /? from the Command Prompt Link to comment Share on other sites More sharing options...
maxXPsoft Posted April 18, 2004 Share Posted April 18, 2004 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 Link to comment Share on other sites More sharing options...
[BM]Crusher Posted April 19, 2004 Share Posted April 19, 2004 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 Link to comment Share on other sites More sharing options...
[BM]Crusher Posted April 19, 2004 Share Posted April 19, 2004 hmm.. i just thought of an easier way@echo offreg /import %systemdrive%-drive.reg Link to comment Share on other sites More sharing options...
Sleepy P Posted April 21, 2004 Author Share Posted April 21, 2004 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... Link to comment Share on other sites More sharing options...
ToBe Posted April 21, 2004 Share Posted April 21, 2004 (edited) %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, 2004 by ToBe Link to comment Share on other sites More sharing options...
ZoSTeR Posted April 21, 2004 Share Posted April 21, 2004 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% Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now