ChatGPT解决这个技术问题 Extra ChatGPT

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

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.?


M
Machavity

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.

Right click on the shortcut of the program, then click on Properties. Click on the Shortcut tab for a program shortcut, then click on the Advanced button. Check the 'Run as administrator' box, and click on OK. Click on OK. Open the program. 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.


W7 prompts everytime to run this program "devenv.exe" , anyway to get rid of that ?
This method doesn't work if opening .sln files directly. Use this other method instead: stackoverflow.com/questions/12257110/…
On Windows 8 this solution did not work for me, use this approach stackoverflow.com/questions/12257110/…
After doing this for some reason it won't allow me to undo this change. VS 2013. arggggg!
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.
T
Timisorean

Try the following steps on Windows 10:

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

Select "Troubleshoot compatibility" :

Select "troubleshoot program": 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.


For Windows 11, before you see that "Troubleshoot compatibility", you have to select "Show more options". The rest is identical
M
Matan Shahar

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


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.
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!
Does not work in all scenarios. Did not work for me in win8 with jumplists. What worked for me was Deblaton Jean-Philippe's solution
This is the incorrect answer. It will still launch under normal (user) privileges when NOT launching from a shortcut.
N
Nate

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 Right click on the file and select Properties Select the Compatibility tab Optional: Select Change settings for all users Select Run this program as an administrator Select Ok and close the dialog

Right click on the file and select Properties

Select the Compatibility tab

Optional: Select Change settings for all users

Select Run this program as an administrator

Select Ok and close the dialog


D
Deblaton Jean-Philippe

Windows 10

Right click "Visual Studio" and select "Open file location Right click "Visual Studio" and select "Properties" Click "Advanced" and check "Run as administrator"


How do you prevent it from prompting?
This only applies to the specific shortcut.
How do you know if VS2017 is running as administrator or not?
Wrong answer. Only works when VS is launched via the shortcut.
M
Mohammad Hossein Amri

https://i.stack.imgur.com/lRXOo.png

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

https://i.stack.imgur.com/9SNKm.png

4- choose advanced

https://i.stack.imgur.com/iBw8Z.png

5- choose Run as Administrator

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


This only works for directly starting it. Not when you open a solution or click a solution from the Recent list.
H
Hadi Salehy

Follow these simple steps:

Right Click on "devenv.exe" Click "Troubleshoot compatibility" Click "Troubleshoot program" Check "The program requires additional permissions" Click "Next" Click "Test the program...". It should launch Visual Studio as Administrator Click "Next" Click "Yes, save these settings for this program" Click "Close the troubleshooter" Now the Visual Studio will always run as Administrator.


How do I remove it though when I need to?
@JohnDemetriou You can go through the same troubleshooting wizard and remove changes it has made.
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 Edge
D
Deblaton Jean-Philippe

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,...


B
Behzad Ebrahimi

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.

https://i.stack.imgur.com/2cqzD.png

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.

https://i.stack.imgur.com/DrBRv.png

https://i.stack.imgur.com/YBcRt.png

https://i.stack.imgur.com/lf07r.png

https://i.stack.imgur.com/qz34q.png


E
Efe ÖZYER

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"

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!!
c
codingpirate

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


C
Community

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.


B
Bob Gilmore

For Windows 8

right click on the shortcut click on properties click on the "Shortcut" tab click on Advanced

You will find Run As administrator (Checkbox)


A
Adeel Kamran

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.


c
cameronjchurch

@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.


I think it's a bad idea to disable the UAC
This is a very bad idea.
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.
This does not answer the question.
I
Iron Mask

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


This is a bad advice. UAC exists for a reason. Just fully disabling if for your whole system is not something to take lightly.
This does not answer the question.
S
Schroedingers Cat

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.