Visual Studio Tip: How to always launch the debugger under a different user profile
One of my team members shared his debug workflow for a set of executables that manipulate Exchange and CRM through webservice calls. This tool always needs to run in the context of a specific service account, even when debugging and testing against the development environment. A practice that needs changing, but until that has been managed, this is how it is.
So for now the developer in question has always used a separate commandline to start the subject under test/debug using the runas /user
command. like so:
c:\> c:\windows\system32\runas.exe /user:domain\username command
Then he attaches the debugger through Visual Studio's debug, attach to process... Even though it's only a few steps, it's hard to use and requires the dev to constantly retype the credentials.
There's a little trick that makes life easier. You still need to open a command prompt at least once and you need to specify one more commandline switch:
c:\> c:\windows\system32\runas.exe /savecred /user:domain\username cmd
You will be prompted for the password for the account in question. Then open the projects properties and navigate to the debug tab, set the startup executable to "c:\windows\system32\runas.exe" and the arguments to "/savecred /user:domain\user YourProjectOutput.exe".
Now when you start the debugger, Visual Studio will automatically launch your application under the right credentials without asking you to supply the password each and every time.
Leave a comment.