About



I am an independent .NET and SharePoint Developer living in The Netherlands. My main focus lies with C# and the .NET Framework but I am also a newbie enthusiast in Ruby and Rails.

View Erik Burger's profile on LinkedIn


MCPD: Enterprise Application Developer

MCTS: WSS 3.0 Application Development


Disclaimer



All opinions expressed in this blog are solely those of the author. You may use all the information provided here but please understand that it is provided "AS IS" and comes with no warranty of any kind.




Recently I’ve been exploring the possibilities of MSBuild in my projects. MSBuild is a command-line tool so this involved spending a lot of time at the Visual Studio 2008 Command Prompt. And having to change directories every time I started a new instance really started getting on my nerves. So, Google to the rescue!

I found plenty of posts on the subject but none of them seemed to work for me. So, I modified the one I found here (thanks devsuldier!). Here are the steps to add the VS2008 Command Prompt to the context menu:

1. Using Notepad, create a file called “VS2008Cmd.reg”. Mind the extension!
2. Copy-paste the following lines into the file:

Windows Registry Editor Version 5.00 
 
[HKEY_CLASSES_ROOT\Directory\Background\shell\VS2008 Command Prompt]
@="Open VS2008 Command Prompt Here"
"Extended"=""
"NoWorkingDirectory"=""
 
[HKEY_CLASSES_ROOT\Directory\Background\shell\VS2008 Command Prompt\command]
@="C:\\Windows\\System32\\cmd.exe /s /k \"cd \"%1\" && \"C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\vcvarsall.bat\"\" x86 "
 
[HKEY_CLASSES_ROOT\Directory\shell\VS2008 Command Prompt]
@="Open VS2008 Command Prompt Here"
"Extended"=""
"NoWorkingDirectory"=""
 
[HKEY_CLASSES_ROOT\Directory\shell\VS2008 Command Prompt\command]
@="C:\\Windows\\System32\\cmd.exe /s /k \"cd \"%1\" && \"C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\vcvarsall.bat\"\" x86 "
 
[HKEY_CLASSES_ROOT\Drive\shell\VS2008 Command Prompt]
@="Open VS2008 Command Prompt Here"
"Extended"=""
"NoWorkingDirectory"=""
 
[HKEY_CLASSES_ROOT\Drive\shell\VS2008 Command Prompt\command]
@="C:\\Windows\\System32\\cmd.exe /s /k \"cd \"%1\" && \"C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\vcvarsall.bat\"\" x86 "

3. Save the file. Double-click the file to add the entries to the registry.

Now, when you Shift+Right-Click on a folder you can select the Visual Studio 2008 Command Prompt. Sweet!

Visual Studio Command Prompt

As a side-note, I ran into the problem that my current workplace resets the registry after rebooting. Annoying as hell, but luckily it’s not difficult to create a little startup script to add the entries to the registry every time I boot up:

1. Create a new file “AddVS2008Cmd.bat”. Again, mind the extension.
2. Copy-paste the following lines into the file:

@echo off
@echo -- Adding Visual Studio 2008 Command Prompt to the Explorer Context Menu
regedit.exe /s "VS2008Cmd.reg"

3. Add a shortcut to the Startup folder. To do this, navigate to Start > All Programs, right-click on the Startup folder and select Explore All Users. Then drag the AddVS2008Cmd.bat file to that folder holding Alt key.
4. Set the shortcut to start minimized. This is purely aesthetics. Right-click on the shortcut, select Properties and change the Run property to Minimized.

Please note that the above paths are only applicable if you are running an English language OS and if you have installed VS to the default location. If you are either running an other language OS or have installed VS to a different location you’ll need to update the paths above. Thank you very much Fritz for pointing this out.

That’s all there is to it. I hope you’ll find this as much of a time-saver as I have.


7 Responses to “Adding the Visual Studio 2008 Command Prompt to your Explorer Context Menu”

  1. 1 Dan

    Sweet! Thanks man…

  2. 2 Gerardo

    Really cool. I can now run my build scripts in a snap.

  3. 3 Erik Burger

    @Dan: No problem. I hope it’s as much of a timesaver for you as it is for me.

    @Gerardo: Exactly what I intended it for! Saves me tons of time :)

    Regards,

    Erik

  4. 4 sumant

    i recieve a msg “registry entry has been disabled bu the user administrator”…
    it flashes for a second only
    pl tell an optimal sol to it

  5. 5 Erik Burger

    Hi Sumant,

    I’m afraid this means that you are not allowed to change the registry. Typically as a developer you are at least a local admin. The best solution I can offer you is to talk to your administrator about this.

    Erik

  6. 6 Fritz Kreh

    For non English windows installations, the path has to be adjusted (replace “program files” by local name). The same applies if VS is not installed to the default path.

  7. 7 Erik Burger

    You are absolutely right Fritz. I’ll update the post to include this note.

    Regards,

    Erik

Leave a Reply