Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Trying to add stuff to the system environment Path via batch, vbs or anything really.

This used to work in a .bat, but has stopped:

setx -m path "C:\addtopath;%PATH%" 

This used to work in VBS, but has also stopped:

Set WshShell = WScript.CreateObject("WScript.Shell") 
Set WshEnv = WshShell.Environment("SYSTEM") 
WshEnv("Path") = WshEnv("Path") & ";C:\addtopath"

This keeps saying invalid syntax when I try to modify the registry:

REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SessionManager\Environment" /v Path /t REG_SZ /d "%path%;C:\addtopath" /f

I am really stumped on this one. I need a solution that will always work. I am running it as administrator, but it still not working.

Cheers,

share|improve this question
2  
What do you mean by "used to work, byt also stopped"? Any errors or just fails silently? –  gronostaj Jul 28 '13 at 8:18
    
How long is your actual PATH value? There have been limits on the maximum length IIRC. –  Mario Jul 28 '13 at 8:27
    
Was getting: Default option is not allowed more than '2' time(s). It did not exceed maxlength. –  user241370 Jul 28 '13 at 8:37
    
Double post: superuser.com/questions/625116/… –  Vlastimil Ovčáčík Jul 28 '13 at 16:22
    
Shouldn't be Session Manager(A space between Session and Manager) –  Marslo Nov 27 at 6:57

1 Answer 1

try to add it into PATH using GUI, right click on My Computer select Properties, and find Environment Variables, then edit the value of PATH

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.