1

My goal is to set %PF% variable to C:\ProgramFiles(x86)\MSBuild\ on x64 machines and to C:\ProgramFiles\MSBuild\ on x86 machines. I can easily achieve that such way

IF DEFINED ProgramFiles(x86) SET PF=%ProgramFiles(x86)%\MSBuild\
IF NOT DEFINED ProgramFiles(x86) SET PF=%ProgramFiles%\MSBuild\

But I want to do that in a single IF ELSE statement.

That one

IF DEFINED ProgramFiles(x86) (SET PF=%ProgramFiles(x86)%\MSBuild\) ELSE (SET PF=%ProgramFiles%\MSBuild\)

fails with unexpected "\MSBuild\" error.

That one

IF DEFINED ProgramFiles(x86) (SET PF="%ProgramFiles(x86)%\MSBuild\") ELSE (SET "PF=%ProgramFiles%\MSBuild\")

runs without errors.

But the result value is not what I need ("%ProgramFiles(x86)%\MSBuild\" - instead of "C:\ProgramFiles(x86)\MSBuild\" on x64 machine for example).

So is that possibe?

2

1 Answer 1

2

use this syntax:

SET "PF=%ProgramFiles(x86)%\MSBuild\"

Note the position of the quotes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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