How do I run Visual Studio as an administrator by default?
Asked Answered
M

19

576

I recently discovered that even while logged into my personal laptop as an administrator, Visual Studio does not run in administrator mode and you need to explicitly use Run As Administrator.

Is there a way to make it run as an administrator by default, other than creating a shortcut, etc.?

Maul answered 11/3, 2012 at 12:15 Comment(0)
H
976

Copied and pasted from here, the Using Advanced Properties section. This will allow you to always have the program run as an administrator when you open it.

  1. Right click on the shortcut of the program, then click on Properties.
  2. Click on the Shortcut tab for a program shortcut, then click on the Advanced button.
  3. Check the 'Run as administrator' box, and click on OK.
  4. Click on OK.
  5. Open the program.
  6. If prompted by UAC, then click on Yes to apply permission to allow the program to run with full permission as an Administrator.

NOTE: If you are doing this is while logged in as standard user instead of an administrator, then you will need to provide the administrator's password before the program will run as administrator.

Haycock answered 11/3, 2012 at 12:21 Comment(10)
W7 prompts everytime to run this program "devenv.exe" , anyway to get rid of that ?Maul
This method doesn't work if opening .sln files directly. Use this other method instead: #12257610Affectional
On Windows 8 this solution did not work for me, use this approach #12257610Singlehandedly
After doing this for some reason it won't allow me to undo this change. VS 2013. arggggg!Subhuman
And also doesn't work with the jumplist - because apparently when using the jumplist you are not really using the shortcut ...Sacristan
For Win7 do the following: right-click devenv.exe -> Properties -> Compatibility -> in 'Privilege Level' section check on 'Run this program as an administrator'Archegonium
For everyone saying the Windows 7 method works on Windows 10; if you use the Windows 7 method on Windows 10 then opening a sln file will not run as administrator. For that to work you need to use the Windows 10 method.Run
It spends ~60 seconds generating a report, crazy - either it's writing a giant repo or something inefficient happening there.Hemitrope
I would also recommend doing the same to VSLauncher.exe too. This is to avoid annoying prompts whether to save changes to devenv.sln when launching VS. See rickvandenbosch.net/blog/…Wisp
Coming from a *nix background, I'm still trying to wrap my head around the idea that you apparently can't just sudo commands up to elevated privileges directly from a command line in Windows. Do I have that right? I must be wrong about that. If not, then, are we seriously supposed to run a development IDE with admin privileges?? Inconvenience aside, does anyone else see maybe just a wee bit of a problem with this idea? Hope your system backups are up to date...Pelotas
P
252

Try the following steps on Windows 10:

  • Search for Visual Studio on the Start window and select "Open file location":

    enter image description here

  • Select "Troubleshoot compatibility" :

    trouble shoot

  • Select "troubleshoot program":

    tobleshoot

    • Raise permissions:

    raise permissions

  • Select "Yes, save these settings for this program"

  • Select "Close"

Once that is done, Visual Studio should be running as administrator.

Petersburg answered 20/1, 2017 at 8:7 Comment(3)
For Windows 11, before you see that "Troubleshoot compatibility", you have to select "Show more options". The rest is identicalDialyse
Great answer, this was especially helpful to make devenev.exe as administrator (not the shortcut), cause I was trying to run it as a macros from the Logitech keyboard.Jenninejennings
This is a very bad idea. I did it once, and about a year later, some of my build tools didn't work. After hours and hours of searching, I found out there was a mismatch because Visual studio was running in Windows 10 mode as a direct result of this, and some build tools ran in windows 11 mode. This created some problems further down the line. It took a lot of time to find out this was the problem.Skirret
L
58

Right click on the application, Props -> Compatibility -> Check the Run the program as administrator

Lipoid answered 11/3, 2012 at 12:20 Comment(4)
I did: right click devenv.exe -> troubleshoot compatibility, run through the wizard and select 'this program needs additional permissions'. Now just double clicking on a .sln will open it as admin.Efta
Indeed it is the best answer, solve my problem too. I just use this on on VS2010 short-cut icon which is pinned inside start menu and it did the work!Authenticity
Does not work in all scenarios. Did not work for me in win8 with jumplists. What worked for me was Deblaton Jean-Philippe's solutionSacristan
This is the incorrect answer. It will still launch under normal (user) privileges when NOT launching from a shortcut.Merchantman
K
43

Windows 10

  1. Right click "Visual Studio" and select "Open file location Right click "Visual Studio" and select "Open file location"
  2. Right click "Visual Studio" and select "Properties" Right click "Visual Studio" and select "Properties"
  3. Click "Advanced" and check "Run as administrator" Click "Advanced" and check "Run as administrator"
Kamalakamaria answered 7/9, 2015 at 16:8 Comment(4)
How do you prevent it from prompting?Pretonic
This only applies to the specific shortcut.Lauber
How do you know if VS2017 is running as administrator or not?Sande
Wrong answer. Only works when VS is launched via the shortcut.Merchantman
H
42

Applying this change will make it so that when you double click on a .sln file Visual Studio will not open. Also, you will not be able to drag and drop files into Visual Studio.

Follow the numbered instructions for each file in the bullited list. The paths are for a standard 64-bit install so you may have to adjust them for your system.

  • C:\Program Files (x86)\Common Files\microsoft shared\MSEnv\VSLauncher.exe
  • C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe
  • C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe
  • C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe

    1. Right click on the file and select Properties
    2. Select the Compatibility tab
    3. Optional: Select Change settings for all users
    4. Select Run this program as an administrator
    5. Select Ok and close the dialog
Hades answered 1/2, 2013 at 18:54 Comment(0)
R
25

image showing how to run visual studio as adminstrator by mhamri step 1 to 3

1- either from start menu or when visual studio is open in the task bar, right click on the VS icon

2- in the context menu, right click again on the visual studio icon

3- left click on prorperties

image showing how to run visual studio as adminstrator by mhamri step 4

4- choose advanced

image showing how to run visual studio as adminstrator by mhamri step 5

5- choose Run as Administrator

click ok all the windows, close the visual studio and reopen again.

Rawley answered 5/5, 2020 at 7:31 Comment(1)
This only works for directly starting it. Not when you open a solution or click a solution from the Recent list.Gasworks
D
22

Follow these simple steps:

  1. Right Click on "devenv.exe"
  2. Click "Troubleshoot compatibility"
  3. Click "Troubleshoot program" Check "The program requires additional permissions"
  4. Click "Next"
  5. Click "Test the program...". It should launch Visual Studio as Administrator
  6. Click "Next"
  7. Click "Yes, save these settings for this program"
  8. Click "Close the troubleshooter"
  9. Now the Visual Studio will always run as Administrator.
Despond answered 28/9, 2014 at 8:51 Comment(3)
How do I remove it though when I need to?Fuchs
@JohnDemetriou You can go through the same troubleshooting wizard and remove changes it has made.Scientist
Yes - this is the only solution that works on Win 10 64 bit and VS 2015. I needed VS as administrator so that I could use Chrome as the PHP debug tool as well as IE and EdgeLubricate
S
19

windows 8

there is no advanced tab anymore. So, to do it automatically, you need to follow the next steps :

-right click on the shortcut
-click on properties
-under the "Shortcut" tab, click on "Open File Location"
-then, right click on devenv.exe
-Troubleshoot compatibility
-Troubleshoot program
-Check "The program requires additional permissions"
-Then next, next next,...

Smoky answered 6/12, 2013 at 11:6 Comment(0)
Z
19

In Windows 10 do the following steps: - Download and install the 'Everything' application that locates files and folders by name instantly. - Find the 'devenv.exe' and locate it.

Everything

  • Right-click on 'devenv.exe' and select "Troubleshoot compatibility". Then select "Troubleshoot program". Then check "The program requires additional permissions". Then test the setting and save setting in next page.

Troubleshoot compatibility

Troubleshoot program

The program requires additional permissions

Run As admin

Zorn answered 9/9, 2019 at 13:23 Comment(1)
Great answer, this was especially helpful to make devenev.exe as administrator (not the shortcut), cause I was trying to run it as a macros from the Logitech keyboard.Jenninejennings
B
13

One time fix :

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]
"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\devenv.exe"="~ RUNASADMIN"
Barytes answered 28/1, 2016 at 7:54 Comment(3)
I needed to add a little to this answer for my needs.... but the short of it is, the HKLM entry was not enough, needed to add the same thing in the HKCU, and remove the tilde from both lines. THANK YOU FOR A SUPER SWEET SOLUTION!!Rescind
The only solution that works on Win10 (2022) but (for me) only when adding to [Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers] not HKLM.Patrilineage
@PhilBlackburn that's what I had to do but in reverse to remove the always run as admin settings, in Windows 11,Undermine
S
4

Right-click the icon, then click Properties. In the properties window, go to the Compatibility tab. There should be a checkbox labeled "Run this program as an administrator." Check that, then click OK. The next time you run the application from that shortcut, it will automatically run as the admin.

Schlueter answered 11/3, 2012 at 12:25 Comment(0)
D
4

Right click on icon --> Properties --> Advanced --> Check checkbox run as Administrator and everytime it will open under Admin Mode (Same for Windows 8)

Damar answered 4/11, 2013 at 15:54 Comment(0)
X
4

To open Visual Studio or Rider, always in admin mode, follow the steps below (works for WINDOWS 11) It works even if you double-click a *.sln file to open. enter image description here

Xanthus answered 6/7, 2023 at 8:43 Comment(0)
E
0

For Windows 8

  1. right click on the shortcut
  2. click on properties
  3. click on the "Shortcut" tab
  4. click on Advanced

You will find Run As administrator (Checkbox)

Epizoic answered 3/6, 2014 at 4:10 Comment(0)
A
0

There are two ways to Run Visual Studio as Administrator:

1. Only 1 time: For this go to startup search bar, search for Visual studio 2017 or what ever version you have, then Right click on VS and Run as Administrator.

2. Permanent or Always: For this go to startup search bar, search for visual studio, right click to it and go to properties. In the properties click on advanced button and check the Run as Administrator check box and then click on ok.

Amelioration answered 10/1, 2019 at 22:10 Comment(0)
S
0

Adding one more solution that doesn't require modifying the app link, works for enterprise and standalone machines, with or without UAC, and best of all - it works on a per-solution or per-project basis.

VSLauncherX A (open source) tool that serves as a launcher for Visual Studio and can be configured for each solution or project independently. Supports specific VS version per solution, multi monitor, launching multiple VS instances at once, admin mode, pre- and post-launch commands, GIT status and much more.

Stuart answered 12/9, 2023 at 10:38 Comment(0)
N
-1

@Kumar

"W7 prompts everytime to run this program "devenv.exe" , anyway to get rid of that ?"

Yes. You can prevent Windows from prompting you by going to Control Panel/User Accounts/Change User Account Control settings and move the slider down.

Nonmetal answered 5/2, 2013 at 19:49 Comment(4)
I think it's a bad idea to disable the UACSmoky
This is a very bad idea.Armillas
I've had UAC disabled since the second it was introduced and have no regrets over the years I've had it that way. The developer is a little more knowledgeable beast.Loudspeaker
This does not answer the question.Incuse
H
-1

In addition to the above suggestion, to setup admin rights for Visual Studio, if you still get the following intermediate prompt; enter image description here

You will have also to click on Show more details or go to Control Panel Security and Maintenance and click on Change User Account Control Settings;

enter image description here

and choose Never Notify:

enter image description here

Hyams answered 21/7, 2021 at 14:48 Comment(2)
This is a bad advice. UAC exists for a reason. Just fully disabling if for your whole system is not something to take lightly.Mankind
This does not answer the question.Incuse
G
-4

I have always done it by creating a shortcut, which is not really much of a problem. I believe there is no way of doing it otherwise.

Ghislainegholston answered 11/3, 2012 at 12:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.