Powershell, Command Prompt and the Visual Studio Command Prompt

As an Enterprise Developer, I often find that there are plenty of batch files I need to run as part of my tool chain, either for code generation, deployment or testing. And its always annoyed me that they needed to be run from the Visual Studio Command prompt.

“oohh… look at me, I am a Visual Studio Command prompt. I am so cool. Only I can run these scripts. I am the greatest ! waahh, waah !”…. pfft … arrogant little command prompt. Who does it think it is? Anyway, where was I? Oh yeah, running these batch files.

So I set out to take down the Visual Studio Command Prompt down a notch, which turned out to be pretty easy. Basically you just need to add some locations to the “Path” environment variable that Visual Studio Command Prompt has, but that an ordinary command prompt and Powershell don’t. An automated version of this process for Powershell can be found here

So find the vsvars32.bat file in your visual studio installation’s “Common\Tools” directory and copy the locations that are being added to the Path variable. See the picture below for more details …
Path
Now add these locations to the end of the Path environment variable and Voila ! Your standard command prompt and Powershell, with all its inherent goodness, will suddenly start running your MsBuild scripts.

  • http://buffered.io/ OJ

    Why not just put the path to vs32vars.bat in your PATH environment variable? Then you can simply “become” a visual studio command prompt at any point?

  • Chaitanya

    It saves you an extra step of typing, plus you get the “double click”/”enter” experience from explorer.


SetPageWidth