For all of the improvements that Windows 10 provides (there are many and you should upgrade ASAP!) it, and Windows 8, go out of their way to keep you from easily getting to the Visual Studio command line.

The Visual Studio command prompt offers many utilities. Several of these utilities don't mean much to programming meatballs like me. Most of them appeal to a far nerdier side of .NET programming spectrum than is ever needed by application programmers. However, there are at least three handy tasks that the VS command line offers to programming meatballs:

  • Investigating assembly contents. ildasm (which sounds like the name of a StarWars overlord, doesn't it?) is the .NET Intermediate Language disassembler. You won't need this on a daily basis, but occasionally, it's handy for understanding or troubleshooting the contents of an assembly. ildasm is good for quick and dirty work, but there are other, more capable free .NET disassemblers. If you only need to quickly example the basics of an assembly, ildasm is serviceable. Try looking at one of your DLLs or EXEs with ildasm sometime--what you'll see is quite interesting.

  • Running Visual Studio unit tests. The VS command line provides access to vstest.console and mstest to run Visual Studio unit tests from the command line.

  • Strong-naming assemblies. For some deployment purposes, you may need to provide strong names for assemblies. The Visual Studio command makes all of the strong-naming utilities easily available.

Visual Studio command prompt batch files

All launching a Visual Studio command line does is add a bunch of path statements with a batch file so that the Visual Studio commands can be found. MS provides a batch file named vcvarsall.bat that launches yet another batch file to set the paths for the Visual Studio command prompt.

vcvarsall.bat is located here for Visual Studio 2013:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat

and here for Visual Studio 2015:

 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat

vcvarsall.bat takes an argument that specifies the processor architecture type you're using. Using that argument, it then launches a processor-specific batch file to set up the Visual Studio command prompt. My PC is x64-based 64-bit so I need to use the 'AMD64' batch file which is located here for Visual Studio 2013:

 C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64\vcvars64.bat

and here for Visual Studio 2015:

 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat

If you are unsure what argument value (and therefore what batch file to use), check your system type against the vcvarsall.bat argument list here.

Make it easy with your own batch file

Create a batch in a folder, in your path named vscmdline.bat with this line for Visual Studio 2013:

 C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64\vcvars64.bat

and this line Visual Studio 2015:

 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat

With that batch file available, starting a Visual Studio command line now is as easy as starting a DOS command line, anywhere you need it, and then calling your batch file with:

vscmdline

Run that batch file and boom, Bob's your uncle, and mstest and all of its cousins are at your fingertips.