Skip to content

Windows 7 & VS Express “Cmd here”

For some reason free users are not entitled to get this little shortcut feature installed with Visual Studio. Being able to open command window fast in some directory is invaluable. Yet it is somehow a “pro” feature :-). Fortunately it is really simple to add this manually. There are many blogs & tutorials explaining how to do it through windows registry. You also download registry scripts that will fix this for you. Only thing is I haven’t seen one that will do this right. Typically they just call vcvarsall.bat, and leave it to explorer to sort out in what directory to start the command prompt. Unfortunately on Windows 7 this does not work satisfactory. Here is one nice blog with such script.

It will add following line to relevant registry keys:

C:\Windows\System32\cmd.exe /k "C:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86

Problem is that it does not pass a name of directory to cmd.exe, so it won’t start in right place. It might worked correctly on previous Windows versions, but it does not in 7.
In Windows 7 if you click in tree-view part of explorers window, it will open command window in directory where cmd.exe itself lives:

If you right click on a folder in folder view, it will open directory one level up. In example, I have clicked on build folder, but it opened command window in src folder:

This is a bit annoying, since you have to CD yourself to right folder after command window is opened.
To fix this pass a name of selected folder to cmd.exe, by adding either pushd %1 or cd %1 as first command on that line:

C:\Windows\System32\cmd.exe /k "pushd “%1” && C:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86

and everything should work correctly.
I have written a small batch script to add correct “Command here” to shell that should work on all versions of windows, with both VS2008 and VS2010. It is probably not difficult to add option for VS .2005 and 2003 I guess. It should also work with other versions of VS but Express (if you need it for some reason). Since it uses environment variable to detect where VS lives on your harddrive instead of hardcoded path, it can’t use .reg files Reg scripts (.reg) can’t expand variables, so it has to be written as batch script. I don’t have 64-bit tools installed the script is written to work only with 32-bit tools, but it should be straightforward to add 64-bit entries as well. You can get it here:

Is there really any valid reason why “Open command window here” is excluded form Express install? It is so trivial to add, that I really see no benefit for Microsoft to exclude it from Express versions.

Post a Comment

Your email is never published nor shared. Required fields are marked *