RunAs A different user when debugging in Visual Studio

后端 未结 7 1035
有刺的猬
有刺的猬 2020-11-29 05:21

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.

7条回答
  •  情话喂你
    2020-11-29 06:14

    cmd.exe is located in different locations in different versions of Windows. To avoid needing the location of cmd.exe, you can use the command moogs wrote without calling "cmd.exe /C".

    Here's an example that worked for me:

    1. Open Command Prompt
    2. Change directory to where your application's .exe file is located.
    3. Execute the following command: runas /user:domain\username Application.exe

    So the final step will look something like this in Command Prompt:

    C:\Projects\MyProject\bin\Debug>runas /user:domain\username Application.exe
    

    Note: the domain name was required in my situation.

提交回复
热议问题