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:
- Use Task Scheduler to create a new task
- Give the task a short name (I called mine “Visual Studio 2022”, set it to Run only when user is logged in
- Use YOUR user
- Check Run With Highest Privileges
- Configure for Win 10/11 whatever works for you
- On the Actions tab
- Create new Start a program action
- Specify full path name to devenv (Visual Studio), no args; “C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\devenv.exe”
- Get nircmd from here http://nircmd.nirsoft.net/win.html (put it on your PATH)
- Add another Start a program action
- Set this action to “nircmd win focus process devenv.exe”
- 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.
- Save the Scheduled Task
- Create a new shortcut on the desktop
- 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.