Spaces in SETX PATH command

Posted by Jeremy Stein on Server Fault See other posts from Server Fault or by Jeremy Stein
Published on 2010-05-04T18:20:18Z Indexed on 2010/05/04 18:28 UTC
Read the original article Hit count: 286

Suppose my PATH is C:\WINDOWS\system32\;C:\Program Files\Important\

SET NEW_PATH=C:\My\Dir\
SETX PATH "%PATH%;%NEW_PATH%"

Results in a path of:

C:\WINDOWS\system32\;C:\Program Files\Important\;C:\My\Dir"

Notice the quotation mark at the end of the path. It's as though the backslash at the end of %NEW_PATH% escaped the final quote mark. I need the quotation marks because I have spaces in my path, but I don't want backslashes to be interpreted as escape characters.

What's the right way to include my PATH in the call to SETX?

© Server Fault or respective owner

Related posts about batch-file

Related posts about environment-variables