The group policy in our environment overwrites the PATH variable every time I log on and, as I run a 'non-standard' computer, it gets it completely wrong (C:\Windows vs C:\WINNT, missing directories etc). Currently, I manually change it every time I log on, but that is starting to get tiresome.
If I use the SET command to change the PATH variable in a batch file, it only has local scope so the change only applies to the commands in the batch file.
set PATH=C:\WINNT;C:\WINNT\System32
set PATH
This batch file will output the new path, but if I run set PATH
on the command line afterwards, it will still be the original path.
How do I set the global PATH environment in a batch file? Or is there another technique I can use?
-
This is edited in system preferences -> [Environment variables]. There you add paths to $PATH
TallGuy : That's what I'm doing at the moment, every time I log on. I want to do it in a batch file so it can be done automatically.From o_O Tync -
You can use the setx command:
setx PATH C:\WINNT;C:\WINNT\System32 /m
Setx is available in Windows 2003 and later, but can be downloaded in the Support Tools for Windows XP.
TallGuy : Brilliant! Thank you.From Phil Ross -
To set your path in the registry so that it propagates to , you can create a PowerShell script that uses some variation of this:
[System.Environment]::SetEnvironmentVariable("PATH", $Env:Path + ";newpart", "user")
But when I tried it just now then looked at System Properties>Environment Variables it not only added my test path, but doubled the existing one. So that problem needs to be worked out.
Based on this page.
From Dennis Williamson
0 comments:
Post a Comment