Visual Studio Run as administrator shortcut
Right-click on the shortcut, select Properties. On the Shortcut tab, click the Advanced button (bottom right). Check the Run As Administrator box.
What I was looking for was a way of running Visual Studio Solution files (.sln) as Administrator
. I just found a pretty good way of doing this...
Place this content inside a file named RunAsAdministrator.reg
:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\VisualStudio.Launcher.sln\Shell\runas\Command]
@="\"C:\\Program Files (x86)\\Common Files\\Microsoft Shared\\MSEnv\\VSLauncher.exe\" \"%1\""
Double click the file to execute it.
Now, when you right click a file you'll have the option of running it as Adminstrator like this:
Here's the full story by the AWESOME David Ebbo: Open your solution files as admin
- Create a shortcut to Visual Studio on your desktop
- Right-click on the program
- "Send to"
- "Desktop (create shortcut)"
- Open up properties
- Right-click on the shortcut
- "Properties"
- Within the "Shortcut" tab, click on "Advanced..." (somewhat towards bottom right)
- Select "Run as administrator" in the new window
- Apply and OK all the windows.
Now when you use this shortcut, it should run the program as administrator.
I know the OP was about how to create a shortcut that runs VS as admin, but using the steps below you can just always have VS launch as admin.
This is a copy of my answer to a similar post on SuperUser:
Option 1 - Set VSLauncher.exe and DevEnv.exe to always run as admin
To have Visual Studio always run as admin when opening any .sln file:
- Navigate to
C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\VSLauncher.exe
. - Right-click on
VSLauncher.exe
and choose Troubleshoot compatibility. - Choose Troubleshoot program.
- Check off The program requires additional permissions and hit Next.
- Click the Test the program... button to launch VS.
- Click Next, then hit Yes, save these settings for this program, and then the close buton.
To have Visual Studio always run as an admin when just opening visual studio directly, do the same thing to the DevEnv.exe file(s). These file are located at:
Visual Studio 2010
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe
Visual Studio 2012
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe
Visual Studio 2013
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe
Visual Studio 2015
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe
Option 2 - Use VSCommands extension for Visual Studio
Install the free VSCommands extension for Visual Studio (it's in the Visual Studio Extensions Gallery) and then configure it to always have Visual Studio start with admin privileges by going to Tools -> VSCommands -> Options -> IDE Enhancements -> General and check off Always start Visual Studio with elevated permissions
and click the Save button.
Note: VSCommands is not currently available for VS 2015, but their site says they are working on updating it to support VS 2015.
My Opinion
I prefer Option 2 because:
- it also allows you to easily turn off this functionality.
- VSCommands comes with lots of other great features so I always have it installed anyways.
- it's just easier to do than option 1.