Visual Studio Run as administrator shortcut
Asked Answered
D

6

29

how do I create a shortcut that runs Visual Studio with Administrator rights?

Actually I have to navigate to the Visual Studio start menu folder, click on the icon with the right mous button and choose "Run as Administrator".

Dkl answered 9/11, 2010 at 10:11 Comment(0)
D
47

Right-click on the shortcut, select Properties. On the Shortcut tab, click the Advanced button (bottom right). Check the Run As Administrator box.

Dalrymple answered 9/11, 2010 at 10:19 Comment(4)
Both of these options are disabled in Windows 10 for meKnowall
@Naomi: I would guess doing this requires you have admin permissions in your windows account. I do have, and I had could do above.Pung
I think I do have Admin Permissions in my Windows Account. How can I verify (or adjust that)? I am the user of my laptop.Knowall
If you wish to create a shortcut to a .sln file and Windows 10 is giving you problems, you could use a software called "Winaero tweaker". It has an option to create an elevated shortcut.Fax
V
13

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:

  1. Navigate to C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\VSLauncher.exe.
  2. Right-click on VSLauncher.exe and choose Troubleshoot compatibility.
  3. Choose Troubleshoot program.
  4. Check off The program requires additional permissions and hit Next.
  5. Click the Test the program... button to launch VS.
  6. 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.
Vascular answered 2/3, 2016 at 17:47 Comment(0)
D
12

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:

enter image description here

Here's the full story by the AWESOME David Ebbo: Open your solution files as admin

Did answered 20/7, 2012 at 15:55 Comment(2)
Many thanks. I could not use the other methods as our network has the box disabled, and therefore no way to mark the shortcut to run as an admin (It may NOT be if I actually wanted to go through the work of logging into my system with my Alt account). However, I was able to use the way you posted, from David Ebbos blog. Since I could just run regedit as admin, using alt account and import the reg file.Liquesce
Thank you so much. Unfortunately this didn't add the menu item where I was hoping to see it. I can see "Run as administrator" when I right-click a .sln in Explorer, but not from the recently opened .slns in my start menu (classic shell start). Rats, but it was worth a shot! :)Vardar
N
9
  1. Create a shortcut to Visual Studio on your desktop
    1. Right-click on the program
    2. "Send to"
    3. "Desktop (create shortcut)"
  2. Open up properties
    1. Right-click on the shortcut
    2. "Properties"
  3. Within the "Shortcut" tab, click on "Advanced..." (somewhat towards bottom right)
  4. Select "Run as administrator" in the new window
  5. Apply and OK all the windows.

Now when you use this shortcut, it should run the program as administrator.

Nardoo answered 9/11, 2010 at 10:20 Comment(0)
A
6

The above answers works, but on Windows 10 you might bump with disabled advanced shortcut screen. So for windows 10 do the following:

  1. Create shortcut to the solution file
  2. Right click the shortcut => properties
  3. Choose Shortcut tab
  4. Under Target add the visual studio executable location before the sln path. For example: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.exe" C:\mypath\example\example.sln
  5. Press Advanced under the shortcut tab - you'll be able to edit the advances window.
  6. Select "Run as administrator"
  7. Press ok
  8. Double click the shortcut - you should be able to run the solution as administrator now.
Algin answered 19/6, 2017 at 14:58 Comment(1)
This is a great solution, it's unfortunate that it cannot be pinned to the taskbar along other VS shortcuts.Kofu
D
3

Ctrl + Shift + Clicking on Visual Studio 2019 shortcut seems to open Visual Studio Professional 2019 in admin mode.

Doenitz answered 7/8, 2020 at 8:12 Comment(1)
This also works for other versions of Visual Studio, because it is actually Windows' feature. Nice one, I didn't know it. +1Allwein

© 2022 - 2024 — McMap. All rights reserved.