DebugExe command-line switch in Visual Studio


Visual Studio (devenv.exe) has a useful command line switch - DebugExe. It allows you to load and start debugging any executable using its file name. It is most useful when debugging startup problems in windows services, when you cannot simply attach debugger to an already running service process. You can find information on how to do that here.

I routinely have to troubleshoot startup problems in a click-once application. Because it is being developed by a large team, building it locally is a non-trivial thing. It is a lot faster to duplicate the problem with our nightly build already deployed on a test server. This is where DebugExe switch is very useful. Unfortunately, those click-once installation directories are very deep and long, you have to do a lot of repetitive keystrokes. I got tired and found an easier way to do this. If you copy the following text into a new .reg file and merge it into registry on your computer, you will be able start debugging an executable by right-clicking it in Windows Explorer and selecting “Debug” from the context menu.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\exefile\shell\debug]
@="&Debug"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\exefile\shell\debug\command]
@="\"C:\\Program Files\\Microsoft Visual Studio 8\\Common7\\IDE\\devenv.exe\" /DebugExe"

Write a Comment

Take a moment to comment and tell us what you think. Some basic HTML is allowed for formatting.

Reader Comments

For those of you on a 64bit Windows, you should instead use the following code:

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\exefile\shell\debug]
@=”&Debug”

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\exefile\shell\debug\command]
@=”\”C:\\Program Files (x86)\\Microsoft Visual Studio 8\\Common7\\IDE\\devenv.exe\” /DebugExe”