I'm trying to change the environment variable in windows 8, however the option to change is inactive.

I tried to change the PATH using the command line, however the path never updated when I closed the command line.

I'm using an administrator account.

Is there anyone who encountered such problem ?

enter image description here

Update, Thanks to @David, I tried the cmd command:

SETX PATH=%PATH%;"D:\Shahar\CodingLibraries\opencv\build\x86\vc10\bin"

Please note that I'm using brackets and there are no spaces in this path ( the path exists on my computer )

Now I get an error from the command line

ERROR: Invalid syntax. Default option is not allowed  more than '2' time<s> 

Which is usually refer when you have space in the new path.

enter image description here

Beside, when I try:


I get the same error.

Any suggestion what should I do next ?

Update 2, I changed to command according to @Daniel

Now the command is the following

SETX PATH="%PATH%;D:\Shahar\CodingLibraries\opencv\" /m

I get an error

Invalid syntax

enter image description here

I tried the follow,

SETX PATH="%PATH%;D:\Shahar\CodingLibraries\opencv\"

I got the same error,

I tried:


I still get a syntax error ... I'm nearly giving up on this...

I tried the same command with back slashes

SETX PATH="%PATH%;D:/Shahar/CodingLibraries/opencv/" /M

Now I get an error that the Length of the command line argument should not exceed 255 characters

Any suggestions on what to do next ? Does the PATH is limit by 255 characters or that's a cmd command limitation ?

enter image description here

  • 1
    Your command is still wrong. There should be no =. See my answer. – DavidPostill Jul 11 '15 at 17:37

I tried to change the PATH it using the command line, however the path never updated

If you use set to change an environment variable the changes are only valid for the current command shell.

  • set - Display, set, or remove CMD environment variables. Changes made with SET will remain only for the duration of the current CMD session.

To make a permanent change use setx instead.

  • setx - Set environment variables permanently, SETX can be used to set Environment Variables for the machine (HKLM) or currently logged on user (HKCU)

I got "ERROR: Invalid syntax. Default option is not allowed more than '2' times"

Your command was:

SETX PATH=%PATH%;"D:\Shahar\CodingLibraries\opencv\buil\x86\vc10\bin"  

The syntax of the above command is incorrect.

To set the user path:

SETX PATH "%PATH%;D:\Shahar\CodingLibraries\opencv\build\x86\vc10\bin"

To set the system path:

SETX PATH "%PATH%;D:\Shahar\CodingLibraries\opencv\build\x86\vc10\bin" /m

Further reading

  • @TripleS Your command syntax was incorrect, answer updated. – DavidPostill Jul 11 '15 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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