Visual-studio – RunAs A different user when debugging in Visual Studio

visual studio

I'm trying to run the program I'm debugging as a different user. Now, this can be done by running the exe and attaching from Visual Studio, but this is cumbersome.

What I've tried to do is use the "RunAs" command:

command.com /C runas /env /user:OtherUser DebugTarget.Exe 

But this is attached to command.com, Visual Studio wants an exe.
Now I can create a dummy app….but anyone have a better solution for this?

Best Answer

As mentioned in have debugger run application as different user (linked above), another extremely simple way to do this which doesn't require any more tools:

  • Hold Shift + right-click to open a new instance of Visual Studio.
  • Click "Run as different user"

    Run as Different user

  • Enter credentials of the other user in the next pop-up window

  • Open the same solution you are working with

Now when you debug the solution it will be with the other user's permissions.

Hint: if you are going to run multiple instances of Visual Studio, change the theme of it (like to "dark") so you can keep track of which one is which easily).