Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug application without admin rights in Visual Studio

I have an application that is intended to run without admin rights, but it fails in that scenario. I tried to run my app as administrator, and it runs. But that's not what I want.

What I want is a way to debug my application without administrator privileges, so that I can determine what is causing it to fail when running as a normal user... so that I at least know what is the cause, and possibly make it in a way that runs without admin rights.

Whenever I run Visual Studio 2015, it starts with Administrator privileges. No way to get rid of that (Administrator) in title bar:

enter image description here

I have tried runas /netonly /user:User devenv.exe to no avail:

enter image description here

If I try to run VS2015 under another more restricted account, it say that it needs Administrative privileges, and does not run:

enter image description here

Clicking "Cancel the task ad return to Visual Studio" won't return to VS, instead it will close.

The problem is that when I run my application without admin privileges it does not open. No messages. Nothing. But when I try to debug it inside Visual Studio it runs... because VS itself only runs as administrator.

Is there a way to debug without admin rights?

like image 361
Miguel Angelo Avatar asked Feb 13 '17 20:02

Miguel Angelo


4 Answers

From one day to the other I faced the same issue with VS 2019.

  1. The "Run as administrator" checkbox was everywhere (every shortcut and exe file) unchecked
  2. Also in the "Troubleshoot compatibility" dialog "The program requires additional permissions" was unchecked.

The solution

Change ownership of the devenv.exe (C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\devenv.exe):

  1. Right-click devenv.exe > Properties
  2. Go to the Security tab.
  3. Click Advanced. (there, Administrator was the owner of the file, in my case)
  4. So click Change to edit the owner of the file to your user account.

Now Visual Studio is launched without administrator rights and therefore also the debugging.

Unfortunately, this must be done after every update.

like image 149
Martin Schneider Avatar answered Nov 03 '22 00:11

Martin Schneider


If you right click on the shortcut and select properties, then select the shortcut tab, there is an advanced button. Click that and you can then select he application to not start in admin mode. Also, be aware that if you are using iis you will need VS to be running in admin mode to debug. Shortcut properties

like image 34
Chris Bartlett Avatar answered Nov 03 '22 01:11

Chris Bartlett


There is something wrong with your Visual Studio installation. It can for sure run without admin. However, you can work around this.

  1. Launch your app as you want, but not from within Visual Studio, but navigate to the built .exe and e.g. double-click it.
  2. Use the Attach to process option in Visual Studio to attach to the process.

If your app fails very quickly this will of course not work, and you will instead need to look into your Visual Studio setup.

like image 2
vidstige Avatar answered Nov 03 '22 00:11

vidstige


So the issue is that it still opened the VS as the admin even if you just open the blank VS IDE in your side, am I right?

Please make sure that you don't enable "The program requires additional permissions" under Troubleshoot compatibility or the property settings for the VS IDE shortcut or the devenv.exe:

https://blog.devoworx.net/2016/01/06/this-task-requires-the-application-to-have-elevated-permissions/

https://superuser.com/questions/547810/how-to-turn-off-always-run-as-administrator-windows-8

like image 1
Jack Zhai-MSFT Avatar answered Nov 03 '22 01:11

Jack Zhai-MSFT