1081

In Windows 7, you could go into a programs compatibility settings and check off to always run as an Administrator. Is there a similar option in Windows 8?

I've always disabled UAC on my machines, and did the same after my Windows 8 upgrade, or so I thought. It turns out there is no off option, only turning off the notifications.

This means nothing is run as an Administrator despite being in the Administrator group. I need to keep closing and reopening my consoles\Visual Studio when I try to debug (attach to process, not F5), which is very frustrating.

It's really annoying that I need to either remember to take extra steps to open it as an Administrator or tell it to close and re-open when I go to debug for the first time.

tak3shi
  • 2,305
  • 1
  • 20
  • 33
Brian Surowiec
  • 17,123
  • 8
  • 41
  • 64
  • 6
    I think this is valid question here, but I think you should ask on SuperUser too - there may be a general answer. – Preet Sangha Sep 04 '12 at 05:10
  • 6
    If VS needs to be launched as an administrator, then your file permissions are wrong. They are easy to mess up with UAC disabled. – KeatsPeeks Mar 01 '14 at 22:10
  • 21
    @Keats Administrative privileges are required to run an ASP.NET application on IIS (as it will attempt to automatically create the virtual directory, etc.) – codemonkeh Mar 16 '14 at 22:47
  • 5
    @camelBase I feel, programs should be made to run as administrator only when needed. Normally they should be run under lower privs. Thats what I do. – VivekDev Apr 26 '16 at 09:02
  • 1
    You should really not do it because if you work with 2 project and only one need to run as an administrator, you should not start the other instance as an administrator. – Phil1970 Aug 20 '19 at 01:27
  • Does this answer your question? [How do I run Visual Studio as an administrator by default?](https://stackoverflow.com/questions/9654833/how-do-i-run-visual-studio-as-an-administrator-by-default) – StayOnTarget Apr 22 '22 at 15:28

13 Answers13

2145

In Windows 8, Windows 10, and Windows 11, you have to right-click devenv.exe and select "Troubleshoot compatibility".

  1. Select "Troubleshoot program"
  2. Check "The program requires additional permissions"
  3. Click "Next"
  4. Click "Test the program..."
  5. Wait for the program to launch
  6. Click "Next"
  7. Select "Yes, save these settings for this program"
  8. Click "Close"

If, when you open Visual Studio it asks to save changes to devenv.sln, see this answer to disable it:

Disable Visual Studio devenv solution save dialog


If you change your mind and wish to undo the "Run As Administrator" Compatibility setting, see the answer here: How to Fix Unrecognized Guid format in Visual Studio 2015

Sachin Joseph
  • 18,928
  • 4
  • 42
  • 62
Siewers
  • 22,626
  • 3
  • 20
  • 31
  • 42
    Likewise, it also resolves pinned solutions being able to run as administrator. Thanks. – Bern Nov 02 '12 at 10:36
  • 189
    You may also want to do this on the `C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\VSLauncher.exe` file if you have multiple versions of Visual Studio installed. Also, the default paths to the devenv.exe files is: 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` – deadlydog Nov 30 '12 at 18:22
  • I don't think this option is available when running VS2012 in Windows 8 – MrGrigg May 01 '13 at 17:18
  • 4
    @MrGrigg It most definitely is working on Windows 8. I just followed these steps above and have VS2012 always running in administrator mode. – Seany84 May 01 '13 at 20:47
  • 1
    Pow! @Seany84 you're right. I had interpreted the instructions wrong, everything is working awesome now. – MrGrigg May 01 '13 at 22:37
  • I used this solution on Windows 8 and now I cannot open any files associated with VS by dbl clicking them in explorer. I also cannot figure out a way to disable what you suggested we try. When I try to run the troubleshooter again unchecking it does nothing and it is checked again when ran a second time. – Cory Gross May 28 '13 at 19:04
  • OK, after much fiddling I managed to disable it by checking the box referring to another version of Windows and choosing Windows 7, also unchecking the box requiring elevated permissions. Were you guys able to get this working while being able to open files from explorer? – Cory Gross May 28 '13 at 19:09
  • 64
    **How do you revert this back to what it was?** – Robert Koritnik Aug 23 '13 at 06:48
  • 105
    @RobertKoritnik This is an equivalent of adding registry entry with name `C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe` and value `RUNASADMIN` under `HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers`. Removing the entry reverts the setting back. – Piotr Szmyd Sep 25 '13 at 17:49
  • 2
    If, for some reason that does not work for you for some reason (as it did for me) - add the entry above to `HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers` instead. – Piotr Szmyd Sep 25 '13 at 17:50
  • This was the fix for Windows 8 where the application in the taskbar could be made to run as admin by setting Right-Click > Properties > Run as Administrator, but any shortcuts would not run as admin. This fixes both. – axeman Nov 13 '13 at 04:38
  • 1
    Wow, it works for me on Visual Studio 2013 on Windows 8.1, Thanks. – Sonal Satpute Dec 29 '13 at 11:30
  • It might say "Saving Settings" for a bit after step 6. Just wait for it, took about 2 minutes for me. – invertigo Mar 06 '14 at 04:28
  • 2
    Following these steps I got an error saying 'devenv.exe is not compatible' for some reason. I followed Piotr Szmyd's advice. This solved the problem. Thanks! – Nullius May 14 '14 at 13:36
  • 1
    It's not a good idea to make this changes - there will be an error(“there was a problem sending the command to the program”) when you make double click on other files. This issue is described here: http://rihanmeij.wordpress.com/2010/06/03/getting-rid-of-%E2%80%9Cthere-was-a-problem-sending-the-command-to-the-program%E2%80%9D-without-compromising-security/ – User Jul 08 '14 at 11:35
  • Works for me on VS2013 and Windows 8.1, thanks so much! – Jakub Arnold Aug 27 '14 at 08:50
  • This solution does not work if you attempt to open VS solution for a virtual drive (created by subst) – niao Apr 29 '15 at 09:42
  • 1
    To revert just chose "Try recommended settings" on Troubleshoot Compatibility – danpop Jun 10 '15 at 10:45
  • How can Windows 8.x be this bad? I have found dozens of good things removed and dozens of bad things added. Are they trying to inflict pain on their users? – HerrimanCoder Jun 18 '15 at 02:51
  • 13
    Works on Windows 10 / VS2015 – Rush Frisby Jul 31 '15 at 14:36
  • 5
    @rushonerok Yes it works with Windows 10, VS2015. The path to `devenv.exe`is `C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe` – valter.santos.matos Aug 03 '15 at 03:29
  • 1
    Or just go to the properties of the program and select the 'Shortcut' tab > 'Advanced..' and tick the box for it there. – paddotk Feb 14 '16 at 17:22
  • 1
    This solution also works for Windows 2012 R2 and Visual Studio 2013. Right click on devenv.exe, select the Compatibility tab, click on "Run compatibility troubleshooter", click on "Troubleshoot program", and check "The program requires additional permissions" – wonster May 02 '16 at 22:03
  • 1
    On my Windows 10 version, right click does not show "Troubleshoot compatibility" anymore. What I did instead: In the taskbar search box, entered "run programs", then clicked "Run programs made for previous versions of Windows.". Then select Visual Studio in the list and the rest is the same. – altumano Apr 26 '17 at 08:50
  • This works for me in windows 10, vs2017; although the settings are a bit simpler: In the tab Compatiblility, there is an option "Run this program as an administrator". When checked, I can click a pinned solution and vs2017 opens as administrator. – Bob Lokerse May 08 '17 at 10:39
  • 1
    I made a *.reg file to apply the Run as Admin settings for VS 2017 and the version selector: https://gist.github.com/liamdawson/3515d9571079bb2ba98c81277654ee23 – Liam Dawson Jan 18 '18 at 03:41
  • 1
    @LiamDawson, this assumes you are running a 64-bit version of Windows. I believe most developers are, it's just an observation :) – Siewers Jan 18 '18 at 12:20
  • Superuser contains instructions for reverting this change: https://superuser.com/a/547846/491934 – Tim Jun 12 '19 at 14:49
  • 1
    Unfortunately does not work on Windows 11 afaict. There is no troubleshooting option after right-clicking the exe. – ruffin Jan 04 '22 at 15:52
179

After looking on Super User I found this question which explains how to do this with the shortcut on the start screen. Similarly you can do the same when Visual Studio is pinned to the task bar. In either location:

  1. Right click the Visual Studio icon
  2. Go to Properties
  3. Under the Shortcut tab select Advanced
  4. Check Run as administrator

setting default operation in admin mode

Unlike in Windows 7 this only works if you launch the application from the shortcut you changed. After updating both Visual Studio shortcuts it seems to also work when you open a solution file from Explorer.

Update Warning: It looks like one of the major flaws in running Visual Studio with elevated permissions is since Explorer isn't running with them as well you can't drag and drop files into Visual Studio for editing. You need to open them through the file open dialog. Nor can you double click any file associated to Visual Studio and have it open in Visual Studio (aside from solutions it seems) because you'll get an error message saying There was a problem sending the command to the program. Once I uncheck to always start with elevated permissions (using VSCommands) then I'm able to open files directly and drop them into an open instance of Visual Studio.

Update For The Daring: Despite there being no UI to turn off UAC like in the past, that I saw at least, you can still do so through the registry. The key to edit is:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
EnableLUA - DWORD 1-Enabled, 0-Disabled

After changing this Windows will prompt you to restart. Once restarted you'll be back to everything running with admin permissions if you're an admin. The issues I reported above are now gone as well.

IAbstract
  • 19,551
  • 15
  • 98
  • 146
Brian Surowiec
  • 17,123
  • 8
  • 41
  • 64
61

NOTE in recent VS versions (2015+) it seems this extension no longer exists/has this feature.


You can also download VSCommands for VS2012 by Squared Infinity which has a feature to change it to run as admin (as well as some other cool bits and pieces)

enter image description here

Update

One can install the commands from the Visual Studio menu bar using Tools->Extensions and Updates selecting Online and searching for vscommands where then one selects VSCommands for Visual Studio 20XX depending on whether using 2012 or 2013 (or greater going forward) and download and install.

undefined
  • 33,537
  • 22
  • 129
  • 198
  • 2
    I installed this after I updated the shortcut permissions so I'm not sure what this does differently. Admin permissions aside this plugin has some nice features that are worth checking out on their own. – Brian Surowiec Sep 04 '12 at 16:55
  • 3
    The VSCommands feature also works when you start a project from a taskbar shortcut's quick access menu. Brilliant stuff! – Sean Kearon Sep 06 '12 at 07:24
  • @BrianSurowiec what it does it put something into the startup of VS so that if its not running with admin it kills itself and starts a new instance with the admin permission – undefined Jan 16 '14 at 19:14
  • @DaveInCaz sadly true. I think he stopped making it. I have edited the answer to note this. – undefined May 08 '18 at 21:08
37
  1. On Windows 8 Start Menu select All Apps
  2. Right click on Visual Studio 2010 Icon
  3. Select Open File Location
  4. Right click on Visual Studio 2010 shortcut icon
  5. Click Advanced button
  6. Check the Run as Administrator checkbox
  7. Click OK
moribvndvs
  • 42,191
  • 11
  • 135
  • 149
Lou
  • 371
  • 2
  • 2
  • 2
    Good answer but will only work when launching from the icon, NOT if you right click on the icon and launch pinned solutions. Tried on Windows 8 and 10 and only the troubleshoot method so far works for me on launching pinned solutions. – djangojazz Jan 07 '16 at 19:51
24

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

Visual Studio 2017

C:\Program Files (x86)\Microsoft Visual Studio\2017\[VS SKU]\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.
deadlydog
  • 22,611
  • 14
  • 112
  • 118
  • 1
    Windows 10 - each time I open .sln file VS 2015 is asking me if I want to save changes to devenv.exe – FrenkyB May 23 '16 at 18:50
  • 1
    @FrenkyB Did you do the steps listed for Option 1 for VS 2015? Setting it to run as admin should fix that issue. http://stackoverflow.com/a/14423461/602585 – deadlydog May 25 '16 at 06:13
  • 1
    It works now. I've just saved devenv.exe and it's not complaining any more. – FrenkyB May 25 '16 at 13:32
15

VSCommands didn't work for me and caused a problem when I installed Visual Studio 2010 aside of Visual Studio 2012.

After some experimentations I found the trick:

Go to HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers and add an entry with the name "C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\VSLauncher.exe" and the value "RUNASADMIN".

This should solve your issue. I've also blogged about that.

Stacked
  • 6,892
  • 7
  • 57
  • 73
Daniel Lang
  • 6,819
  • 4
  • 28
  • 54
7

I know this is a little late, but I just figured out how to do this by modifying (read, "hacking") the manifest of the devenv.exe file. I should have come here first because the stated solutions seem a little easier, and probably more supported by Microsoft. :)

Here's how I did it:

  1. Create a project in VS called "Exe Manifests". (I think any version will work, but I used 2013 Pro. Also, it doesn't really matter what you name it.)
  2. "Add existing item" to the project, browse to the Visual Studio exe, and click Okay. In my case, it was "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe".
  3. Double-click on the "devenv.exe" file that should now be listed as a file in your project. It should bring up the exe in a resource editor.
  4. Expand the "RT_MANIFEST" node, then double-click on "1" under that. This will open up the executable's manifest in the binary editor.
  5. Find the requestedExecutionLevel tag and replace "asInvoker" with "requireAdministrator". A la: <requestedExecutionLevel level="requireAdministrator" uiAccess="false"></requestedExecutionLevel>
  6. Save the file.

You've just saved the copy of the executable that was added to your project. Now you need to back up the original and copy your modified exe to your installation directory.

As I said, this is probably not the right way to do it, but it seems to work. If anyone knows of any negative fallout or requisite wrist-slapping that needs to happen, please chime in!

Jim Strawn
  • 71
  • 1
  • 3
  • If you do this, it will then become impossible to run the app as a LUser, and nothing should be allowed to run with administrative privileges unless they're required for a known, good, reason (such as auto-configuring IIS) – EKW Oct 11 '17 at 12:38
7

Also, you can check the compatibility troubleshooting

  • Right-click on Visual Studio > select Troubleshoot compatibility.
  • Select Troubleshoot Program.
  • Check The program requires additional permissions.
  • Click on Test the program.
  • Wait for a moment until the program launch. Click Next.
  • Select Yes, save these settings for this program.
  • Wait for resolving the issue.
  • Make sure the final status is fixed. Click Close.

Check the detail steps, and other ways to always open VS as Admin at Visual Studio requires the application to have elevated permissions.

Mohamed
  • 806
  • 13
  • 30
7

NONE of this worked for me. The way I got it to start allways as Administrator was to modify the registry.

1. Just start regedit.exe.
2. Navigate to Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
3. Right Click New->String Value
4. Add C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\devenv.exe (or the correct path for your system)
5. Right Click on this entry and select Modify.
6. Add for Value Data: ~ RUNASADMIN.

ALL DONE.

Gogu CelMare
  • 699
  • 6
  • 15
6

If you using Total Commander as I do, you should do the same for Total Commander to be run as admin always. Then you will be able to open sql file on double click in same SQL Server management instance, or to open any Visual Studio file on double click and not have multiple instances open.

This Troubleshoot program adds registry value to HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers for any program, so if you like to write it directly you can.

drejKamikaza
  • 96
  • 1
  • 5
  • 1
    It basically adds a new string value to that registry path, with the name being the full path to the executable (without quotes), and the data being `RUNASADMIN`, in case you want to do it manually. – Ray Apr 04 '16 at 11:59
6

I found a simple way to do this on EightForums (Option 8), create a string value under HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers. Set the name to the path to the program and the value to ~RUNASDMIN. Next time you open the program it will open as an administrator

[HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]
    "C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\Common7\\IDE\\devenv.exe"="~RUNASADMIN"
Mike
  • 857
  • 1
  • 16
  • 29
5

Just find the program in Program Files directory (or in other location). Right click on the EXE file, on the second tab at the bottom check the checkbox of forcing running that program with administration privileges. From now all shortcuts of the exe file will be fired with administration privileges :)

BlueMan
  • 687
  • 2
  • 10
  • 23
  • 2
    This works on all systems where the Properties window has a Compatibility tab, which Windows 8 doesn't (although Windows 8.1 does). – ThePyroEagle May 03 '16 at 20:18
3

Visual Studio does elevate itself automatically if the project's application manifest specifies an administrative requestedExecutionLevel, so you just need to edit that. Visual Studio will detect that and relaunch itself as administrator when needed.

beppe9000
  • 1,056
  • 1
  • 13
  • 28