daddydave Posted January 10, 2007 Posted January 10, 2007 I am writing a batch file to add a directory to the Path, reg.exe style.@echo off rem I used DoesNothing value while testing but will use the Path valueset Sysenvt=HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environmentfor /f "tokens=3* delims= " %%f in ('reg query "%SysEnvt%" /v DoesNothing') do set Currntpth=%%freg add "%SysEnvt%" /v DoesNothing /t REG_EXPAND_SZ /d "%Currntpth%;%%ProgramFiles%%\Windows Resource Kits\Tools" /fThat should be a tab character after delims=.I managed to get it working exactly the way I want, but I was wondering if it could be improved. If I do the embedded req query by itself:reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PathOne of the lines says! REG.EXE VERSION 3.0I'm not clear on what happens to this line, is it guaranteed to get ignored by the for /f processing?(Testing in XP)
IcemanND Posted January 10, 2007 Posted January 10, 2007 Am I missing something? Why not use the %PATH% variable?@echo offrem I used DoesNothing value while testing but will use the Path valueset Sysenvt=HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environmentreg add "%SysEnvt%" /v DoesNothing /t REG_EXPAND_SZ /d "%PATH%;%%ProgramFiles%%\Windows Resource Kits\Tools" /fI'm assuming this is still your testing code since 'DoesNothing' should be 'Path' if you are really trying to add this to the 'Path' variable.
daddydave Posted January 10, 2007 Author Posted January 10, 2007 (edited) Am I missing something? Why not use the %PATH% variable?I was originally trying to avoid adding a User environment var to the System environment, but now that you mention it, I'm only dealing with this one variable, and PATH seems to be pretty much always in the System environment , so that concern may be unwarranted. Edited January 10, 2007 by daddydave
daddydave Posted January 11, 2007 Author Posted January 11, 2007 Am I missing something? Why not use the %PATH% variable?I was originally trying to avoid adding a User environment var to the System environment, but now that you mention it, I'm only dealing with this one variable, and PATH seems to be pretty much always in the System environment , so that concern may be unwarranted.My way didn't work with the reg.exe version (2.0) that was made for Win2K, your way did. Thanks!
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