Visual Studio 2010 Command Prompt Here On the Context Menu of Windows Explorer

You use keyboards and command line more and more, as you get more experienced with the tools in development. If you install git on windows, it creates “Git bash here” context menu on Windows Explorer. It is really handy, and I like it. I believe Visual Studio installation should do the same.

Well, it doesn’t, but you can create it, if you want, with the little manipulation of windows registry.

First, open regedit. Make sure you export the current settings as backup, as your mistake can paralyse your system.

Second, Create two registry keys to enable the context menu on Windows Explorer.

  • HKEY_CLASSES_ROOT\Directory\shell\vs_cmd
  • HKEY_CLASSES_ROOT\Directory\shell\vs_cmd\command

The values are like these

HKEY_CLASSES_ROOT\Directory\shell\vs_cmd

  • Name: (Default)
  • Type: REG_SZ
  • Data: Visual Studio 2010 Command Prompt Here
HKEY_CLASSES_ROOT\Directory\shell\vs_cmd\command
  • Name: (Default)
  • Type: REG_SZ
  • Data: cmd.exe /s /k pushd “%V” && “C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat” x86

Then go to windows explorer and right-click on any directory. You will see a menu “Visual Studio 2010 Command Prompt Here”

Let me explain what’s happening here.

  • “HKEY_CLASSES_ROOT\Directory\shell” is where you put settings for your windows shell.
  • cmd.exe is reachable from any directory, so you don’t have to specify the full path to execute it.
  • /s means to strip quote characters from the command_line (http://ss64.com/nt/cmd.html)
  • /k means to carry out a command but the shell remains without closing.
  • pushd let you execute cmd.exe with a given directory (http://www.hanselman.com/blog/PUSHDReminderItAutomaticallyMapsNetworkDrives.aspx)
  • vcvarsall.bat is a batch file executed when you run visual studio command prompt.

 

I also referenced the below nice posts.

but eventually, I used git’s “bash shell here” registry settings.

 

Visual Studio 2010 Command Prompt Here On the Context Menu of Windows Explorer