Running vcbuildtools.bat in PowerShell on startup in cmder

1

Usage of the command prompt is disabled here, so when I want to use the Visual C++ Build Tools (i.e. enable the usage of cl), I have to use PowerShell. I use the following line, which works fine:

cmd.exe /k "C:\Program Files (x86)\Microsoft Visual C++ Build Tools\vcbuildtools.bat" x86_amd64 `& powershell

However, I want to try and run this command automatically whenever I try to start up cmder. I have this line specified in the 'Command line' area of the startup settings, but it gives the following error:

Error in script usage. The correct usage is:
    "C:\Program Files (x86)\Microsoft Visual C++ Build Tools\vcbuildtools.bat" [option]
where [option] is: x86 | amd64 | x86_amd64 | x86_arm | amd64_x86 | amd64_arm
ECHO is off.
For example:
    "C:\Program Files (x86)\Microsoft Visual C++ Build Tools\vcbuildtools.bat" x86_amd64

What do I need to change in the line to get it to work?

James Whitehead

Posted 2018-02-14T10:59:33.477

Reputation: 13

1Why have you got a backtick before the &? – DavidPostill – 2018-02-14T11:04:53.093

Oh, thank you! I had the backtick when I was running the script from PowerShell itself because the & needed to be escaped, but I forgot that cmder wasn't running it from PowerShell to begin with. Problem (indirectly) solved. – James Whitehead – 2018-02-14T11:14:59.577

Answers

0

What do I need to change in the line to get it to work?

cmd.exe /k "C:\Program Files (x86)\Microsoft Visual C++ Build Tools\vcbuildtools.bat" x86_amd64 `& powershell

Remove the backtick ` from `&.

The ` escapes the & so the reset of the line gets passed as parameters to vcbuildtools instead of being interpreted by cmd.

DavidPostill

Posted 2018-02-14T10:59:33.477

Reputation: 118 938