Running Visual Studio as Admin Without the UAC prompts

Filed under .NET, Visual Studio

For several projects I work on, I need to load Visual Studio (2022 Enterprise edition) in “admin” mode.

That’s easy enough to do, but I always have to click through the UAC prompts, which is tiresome.

Turns out there’s a (relatively) easy way around this.

I stumbled across this article by Lowell Heddings on how to “Create Administrator Mode Shortcuts without UAC prompts” accidentally which clued me in that this was even possible. I highly recommend checking it out.

I’ve embellished the technique slightly because I found that VS would end up coming up behind all the other open windows, which is even worse than the UAC prompts.

I’ll summarize the process below:

  1. Use Task Scheduler to create a new task
  2. Give the task a short name (I called mine “Visual Studio 2022”, set it to Run only when user is logged in
  3. Use YOUR user
  4. Check Run With Highest Privileges
  5. Configure for Win 10/11 whatever works for you
  6. On the Actions tab
  7. Create new Start a program action
  8. Specify full path name to devenv (Visual Studio), no args; “C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\devenv.exe”
  9. Get nircmd from here http://nircmd.nirsoft.net/win.html (put it on your PATH)
  10. Add another Start a program action
  11. Set this action to “nircmd win focus process devenv.exe”
  12. On the Settings tab, make sure that the combobox near the bottom says “Run a new Instance in parallel” and not “Do not start a new instance”. That way, you can still launch multiple instances of Visual Studio if you need to.
  13. Save the Scheduled Task
  14. Create a new shortcut on the desktop
  15. For the shortcut path use “C:\Windows\System32\schtasks.exe /run /tn “{your task name from step 2 above}”

And that’s it.

If everything’s kosher, dblclicking on that shortcut will launch VS in Admin mode, in the foreground, with no UAC prompting.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*