How to set PATH to another variable value with spaces in Windows batch file

Posted by Evgeny on Stack Overflow See other posts from Stack Overflow or by Evgeny
Published on 2010-05-05T07:30:14Z Indexed on 2010/05/05 7:38 UTC
Read the original article Hit count: 170

Filed under:
|
|
|

I've got a Windows batch script issue that I'm bashing my head against (no pun intended). The problematic script looks like this:

if defined _OLD_VIRTUAL_PATH (
    set PATH=%_OLD_VIRTUAL_PATH%
)

When I run it and _OLD_VIRTUAL_PATH is set I get:

\Microsoft was unexpected at this time.

_OLD_VIRTUAL_PATH is a variable that was originally set from PATH and it contains spaces - I'm pretty sure that's the problem. But what's the solution? It runs successfully if I enclose it in quotes, but I don't think the entire value of the PATH variable is supposed to be in quotes.

© Stack Overflow or respective owner

Related posts about Windows

Related posts about batch