Tip Debugging as elevated admin

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,799
Location
Norway
Programming Experience
10+
Running VS non-elevated will not make debugger request elevation for the debugged app by itself. This is something I had to search a while to find, so I share this simple tip here. Maybe I should have thought of doing that myself, but I had to search a long while before I found this in a forum thread somewhere:
  • If you have an application with requireAdministrator in manifest you can make it run as elevated administrator during debug simply by running VS as administrator first (context menu on shortcut).
Note that doing this will not show the usual warning about 'allow this program to make changes to computer' when you start debugging, that happens only when first starting VS as admin.

Another approach (that I wanted to avoid) was to run the app as admin manually, and then use Tools menu item in VS to "Attach to process". A non-elevated VS will ask to restart elevated in this case. Anyway much more cumbersome.

During research I also found this VSCommands extension for VS, the pro version ($49) has Run/Debug as Different User feature. I have not tried this extension (yet).
 
Back
Top