A while back, I wrote a WinBatch script to check the PATH for errors; duplicate
and missing folders. They could slow the system down, especially on those older,
slower machines. Neither DOS nor Windows will give you an error message if this
kind of error exists. And you'd be surprised how often an error like this does
exist! I'd say %80 of all machines have one.
Anyway, I never finished the script, but it was no skin off my back to copy
and paste this code for you. This is not exactly a gift horse, but its a valuable
skill to be able to take someone else's code and modify it to your needs.
NewFolder=""
; Read the PATH into a Winbatch variable
Title="Test"
Path=Environment("path")
Pause("Hit OK if Path is below:",Path)
;Join, or conCATenate NewFolder with Path
NewPath=Strcat(Path,";",NewFolder)
;Now set the new value for the path
EnvironSet("Path",NewPath)
exit
===============================================================
There's another, or second, way to do this. Accessing the registry is more
complicated, but a bit more versatile. For instance, you should be able to access
the SYSTEM path as well the USER path. You use a different constant as a first
parameter in RegOpenKey(). I can't, however, remember what that is.
NewFolder=""
; To access the registry you have to get a "key", which is sort of
; like a handle except that you specify the target location (in the
; registry) relative to that key.
RegKey=RegOpenKey(@REGCURRENT,"Environment")
if RegKey==0 then goto ErrorLabel
; Now fetch the User path from the registry
UserPath=RegQueryValue(RegKey,"[Path]")
; Join, or conCATenate NewFolder with Path
NewPath=StrCat(UserPath,";",NewFolder)
;Now set the new value for the path
RegSetValue(RegKey,"[Path]",NewPath)
; Just like a handle, you have to CLOSE the key or your changes won't take.
RegCloseKey(RegKey)
Exit
When you're done testing either of these routines open a Command Prompt
and type SET to see all the Environment variables to check PATH=.
Best O'Luck,
Robert