[visual-studio] Can you force Visual Studio to always run as an Administrator in Windows 8?

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.

This question is related to visual-studio windows-8 uac

The answer is


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.


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 :)


  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

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.


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.


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.

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!


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.


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.


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"

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.


Examples related to visual-studio

VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio? How to download Visual Studio Community Edition 2015 (not 2017) Cannot open include file: 'stdio.h' - Visual Studio Community 2017 - C++ Error How to fix the error "Windows SDK version 8.1" was not found? Visual Studio Code pylint: Unable to import 'protorpc' Open the terminal in visual studio? Is Visual Studio Community a 30 day trial? How can I run NUnit tests in Visual Studio 2017? Visual Studio 2017: Display method references

Examples related to windows-8

How to install and use "make" in Windows? How do I create a shortcut via command-line in Windows? Signtool error: No certificates were found that met all given criteria with a Windows Store App? How to open/run .jar file (double-click not working)? Forbidden: You don't have permission to access / on this server, WAMP Error How can I set / change DNS using the command-prompt at windows 8 "Unable to launch the IIS Express Web server" error Can't ping a local VM from the host Viewing localhost website from mobile device How to download/upload files from/to SharePoint 2013 using CSOM?

Examples related to uac

XAMPP installation on Win 8.1 with UAC Warning Can you force Visual Studio to always run as an Administrator in Windows 8? How can I auto-elevate my batch file, so that it requests from UAC administrator rights if required? How to run a program automatically as admin on Windows 7 at startup? HttpListener Access Denied How to request Administrator access inside a batch file Requested registry access is not allowed Request UAC elevation from within a Python script?