Sunday, April 11, 2010

Shell Utilities – Visual Studio Command Prompt



Have you ever wished for a feature, similar to “Open Command Window here”, for “Visual Studio Command Prompt”? If yes jump in.


Any developer, who frequently use “Visual Studio Command Prompt” for command line compilation or for other related tasks, might have faced with the dilemma of navigating to the directory where the source code is located. Even though this is trivial task, I like to make things even simple and better.

When you open the "VS.NET Command Prompt" you will notice that, by default the path points to where Visual Studio is installed, making our task of pointing to the directory of our choice a bit tedious. I decided to iron out this irksome step; the solution that immediately turned up in my mind was similar to the one in my previous post “Shell Utilities – The Command Prompt”.


If the above download link didn’t work, follow the given steps
  1. Copy the below text and save it to a batch file named “vsnet2008.bat” (save to C:\ drive, or in any drives root like D:\, F:\ etc)




    @cd %1
    @COLOR 0A
    @%comspec% /k ""C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"" x86
  1. Copy the below text and save it to a batch file named “VSCmdPrompt.reg” (to any location you wish)



Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\VSCommandPrompt]
@="Open VS.NET 2008 Command Prompt"

[HKEY_CLASSES_ROOT\Directory\shell\VSCommandPrompt\command]
@="C:\\vsnet2008.bat %L"

Execute the following steps to get things rolling.
  1. First of all, you need to have “Visual Studio.Net” installed in you PC.
  2. Secondly you need to have admin rights, which i presume for every developer.
  3. Extract the zip file downloaded from the above link(if you couldn't download, skip this step.)
  4. Open “VSCmdPrompt.reg” and “vsnet2008.bat” in notepad (I prefer Notepad++)
  5. Open the “Properties” dialog for “Visual Studio Command Prompt”.
    (You can find in “Start
    à Programs à Microsoft Visual Studio 2008 à Visual Studio Tools à Visual Studio 2008 Command Prompt”)
  6. Copy the contents in “Target” field; under “Shortcut” tab.
    it should look like the following for 32-bit systems; for 64-bit systems the x64 will be shown in place of x84.



  7. %comspec% /k ""J:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"" x86
  1. Open “vsnet2008.bat” in editor and overwrite the third line with the copied contents. Make sure the “@” character is not overwritten.
  1. Save the batch file, make sure the batch file is in the root drive. (say C:\, D:\, F:\ etc)
  1. Open “VSCmdPrompt.reg” in editor; specify the path where the batch file is located. If you had saved the batch file in a root drive, then you just needed to change the drive letter.
  1. Save the “VSCmdPrompt.reg”.
  1. Double click the “VSCmdPrompt.reg” file. Click “Yes” for the confirmation message. You are Done, thats all.


Now you should be able to trigger "VS.NET 2008 Command Prompt" from any directory of your choice.




No comments: