1. Technology

The Visual Studio Command Prompt

By August 17, 2010

Follow me on:

... so I was reading along in this book ...

"ASP.NET ships with a tool (that) you can easily call from within a Visual Studio Command Prompt window. ... you should launch the tool from a Visual Studio Command Prompt window, as it includes the necessary path information to the .NET Framework directory containing the necessary tools."

Visual Studio Command Prompt window??? There was no explanation about that in the book. (Don't you just hate that!)

First, you don't have to tell me about DOS. That was my first PC OS. In fact, it was the first five or six. I was one of those, "Oh Wow! Windows is cool because there is this thing called a mouse!" But I didn't know that there was a Command Prompt window already in Visual Studio. So I fired it up and started looking.

There is a window called, "Command Window" under the View > Other Windows menu. That isn't it. Intellisense works a treat in that window, but all you can execute are VS things. As the doc says, "commands or aliases directly in the Visual Studio integrated development environment (IDE)." No, in fact, what you have to do is (again quoting the online doc), "Click Start, point to All Programs, point to Microsoft Visual Studio, point to Visual Studio Tools, and then click Visual Studio Command Prompt."

I'm like, that's marvelous! ... It's easier to start DOS by entering "cmd" in the Start button Run box.

Let's look at the "Visual Studio Command Prompt" in more detail. It appears to just set the path for you and put you in (Ta Da!) the VC directory under Visual Studio. Not even the C# directory and certainly not the VB directory. I guess they assume that anyone who uses this tool is really hard core and programs directly against the hard drive with a magnifying glass and a magnet.

What it actually does is run this DOS command. (In my case.)

%comspec% /k ""C:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" x86

What does vcvarsall.bat do? Well, it sets the target compiler environment so you can compile code for a different processor. Like I said, "hard core".

You can find other pages where they just tell you to use that command string and don't tell you what it means. I suspect that they just copied it from the shortcut Properties and didn't bother to figure it out. %comspec% and /k are OK. %comspec% just points to the directory where DOS ... uhhh ... "the Command emulator" ... is and /k just keeps a secondary session active so the window doesn't close. I also recommend Prompt $P to add the path to the command prompt. But x86 targets the Intel 32 bit compiler, which is fine for most of us. But what if you're using an AMD64 processor (one of the other choices). I don't know if the Visual Studio install is smart enough to change that argument automatically or if you just get the wrong target. More to the point, why do they assume that this is what you want to do in the first place?

Without further ado, here's how to make a tool that you can call up from inside the Visual Studio environment.

  • Select Tools > External Tools in Visual Studio. Click the Add button.
  • Fill in the Title. (I called mine DOS. Yeah, yeah, yeah. I know it's not really DOS.)
  • Enter cmd.exe in the Command textbox.
  • Enter %comspec% /k Prompt $P in the Arguments textbox.
  • Pick an Initial directory. I use $(ProjectDir).
  • Click Apply and OK and you're ready to roll.
August 19, 2010 at 6:54 am
(1) Sam Borys says:


I salute you. Thanks for unraveling some of the “mysteries” of MS VS. I’m using the VS Express 2010 at this point.
I hope your gem of advice will help get some extra “mileage”
out the of the Express.

Sam Borys

August 26, 2010 at 8:20 am
(2) Nunez Reinaldo says:

That was a great explanation and solution….Thanks a bunch for taking the time to explain!!!

August 28, 2010 at 11:38 am
(3) Dan says:

I had no idea that there was a VB command prompt. looks like I’ll be using it!

December 4, 2010 at 12:13 am
(4) Xanadu says:

Download Windows SDK.
Exemple, download Windows SDK for Windows 7 and
.Net (Framework) 4.

January 20, 2011 at 3:03 pm
(5) Karen Schmidt says:

OMG I have been trying to execute a command all morning in the Command Window, and I have about 10 Google IE tabs open trying to figure out why it was complaining. Thanks so much for clarifying how the command prompt and the command window are not the same in VS! Props to you my friend.

September 4, 2011 at 8:14 am
(6) Brian McCumber says:

Below is a shortcut target and bat file code to set up a custom .net dos programming environment. It’s portable and I’ve moved it from xp to vista to 7 and it works with all those operating systems. You can type edit at the command prompt and use the old dos editor to write vb or c++ modules then compile them using the command line compilers. I’ve written a bunch of modules using this. You have to make sure the bat file and shortcut are in the same directory.

shortcut path

C:\WINDOWS\system32\cmd.exe /k “”C:\VbCmdDevEnv\dotNetVars.bat”"

Batch File

@Set Path=C:\Windows\;C:\Windows\System32;C:\Windows\Microsoft.NET\Framework\v2.0.50727\;%PATH%
@Set LIB=C:\Windows\Microsoft.NET\Framework\v2.0.50727\;%LIB%
@Set INCLUDE=C:\Windows\Microsoft.NET\Framework\v2.0.50727\;%INCLUDE%
Color 0A
@echo Command line compiler environment set.
@echo ——————————————————-
@echo Usage Example “C:\>vbc filepath\fileName.vb”
@echo This will compile an exe from a vb module and place it
@echo in the same directory as the vb module file.
@echo ——————————————————-

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>
Top Related Searches
  • command prompt
  • visual studio
    1. About.com
    2. Technology
    3. Visual Basic

    ©2014 About.com. All rights reserved.