37

Whenever I start Visual Studio 2012 in Windows 8 it always needs Administrator permissions to access IIS meta data and debug local web applications on IIS.

If I turn UAC off, I cannot launch the Windows 8 simulator!

Does anyone know how I can get it to stop with all this security nonsense and just let me get on with my work?

7

8 Answers 8

27
  1. Right click on the "Metro" Icon for Visual Studio 2012

  2. Click "Open File Location". It will put you into the classic windows desktop with the shortcut for Visual Studio.

  3. Right-Click on that shortcut and go to "Properties"

  4. Click "Advanced"

  5. Check "Run as Administrator" and click OK.

From now on, it will always launch as Administrator with elevated privileges.

You will need to do this for every shortcut you have to Visual Studio.

I.e., if you also have pinned Visual Studio to the task bar.

  1. Right-Click the icon.

  2. Right-Click 'Visual Studio 2012'

  3. Then carry on from step 3 above.

6
  • 3
    Do you also know of a way to turn on 'Run as Admin' by default? On Windows 8 they seem to have made it to run as User only, sensible for end users, but for devs, we get a useless 'permission needed' dialog all the time you can just click through anyway.
    – user154419
    Aug 25, 2012 at 1:21
  • 1
    I still don't know of a way of making the 'Run As Admin' preference stick when launching a pinned or recent solution from the taskbar.
    – user154419
    Aug 25, 2012 at 1:28
  • 9
    This is not an effective answer. For example if you open Visual Studio by opening a project/solution instead of via a devenv.exe shortcut it won't be running as elevated/Administrator. Aug 30, 2012 at 0:41
  • 4
    FerretallicA's answer is the right one. Jan 24, 2013 at 23:16
  • 1
    @uosɐſ I agree - this isn't the answer as it only works for the program itself not launching .sln files that need VS2012 directly. Check FerretallicA answer Mar 2, 2013 at 10:59
52

The Only way I'm aware of which ensures it will always open as Administrator (including when you open from file associations, jump list etc) is:

  1. Locate the devenv.exe file in Explorer eg mine is in C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\

  2. Right-click devenv.exe and choose "Troubleshoot compatibility"

  3. Select "Troubleshoot program"

  4. Select "This program requires additional permissions"

You'll need to let it launch VS before it lets you click Next, but then you're done.

EXTREMELY annoying that you can't just do this through the normal properties dialog any more. It's like Microsoft are going out of their way to ensure Windows 8 alienates as many people as possible...

1
  • 2
    This Troubleshoot Compatibility is the way to go - takes care of all your shortcuts and pinned items at once! This should be the marked answer. Jan 24, 2013 at 23:14
6

Had the same issue, teammate suggested solution that worked for me is to install VSCommands for Visual Studio 2012, then open VSCommands config, set IDE Enhancements - General - Always start Visual Studio with elevated permissions.

5

I posted about this on Stack Overflow before finding this question and then tried everything the other answers here suggested. I started running into some issues right away though.

When running VS2012 with elevated permissions I was no longer able to drag & drop files into it from Explorer which I assume is because Explorer isn't running with elevated permissions.

Then after I used VSCommands to always run Visual Studio with elevated permissions I was no longer able to open files associated with Visual Studio, aside from solution files, by double clicking them in Explorer. Visual Studio would open but then I'd get an error saying There was a problem sending the command to the program. and they wouldn't open.

This left me having to use the open file dialog if I wanted to open any non solution/project file.

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.

3
  • Thanks for such a detailed answer. Unfortunately, the metro apps, like SkyDrive will not operate without UAC turned on. So I'm afraid this is not a viable solution. The only way is to set "Run as admin" in devenv.exe's compatibility settings. thanks Sep 6, 2012 at 7:47
  • I'm running version 16.4.6010.0727 of SkyDrive and it's syncing my files just fine. I don't have overlay icons anymore when in the SkyDrive folder but the syncing still works. As for the metro apps...I'm staying clear of them. Not only do I not like that part of win8 but it just makes life more difficult for me, as you can see with this UAC stuff. By the looks of it though that seems to be their goal with win8 & vs2012. Sep 6, 2012 at 8:07
  • I'm not sure why you don't like metro, it's just a load of icons and apps, much like Windows 1.0 to Windows 7, except the icons are squarer and the apps are full screen. I don't know why your life is harder, given that when you press start and type something, the list pops up and you hit enter like normal. Sep 6, 2012 at 11:52
4

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 2019

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\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.
4
  • vscommands.squaredinfinity.com doesn't seem to be available for VS 2015.
    – Naomi
    Apr 13, 2016 at 16:46
  • 1
    @Naomi Yeah, I Noted that in my post. They say they are working on it though, so hopefully they will have a VS 2015 compatible version later this year.
    – deadlydog
    Apr 13, 2016 at 17:45
  • BTW, I tried the first option yesterday for the launcher in my Windows 10 and it didn't work. VS still starts normally. I also can not change shortcut Advanced properties - they are disabled for me
    – Naomi
    Apr 13, 2016 at 21:42
  • @Naomi hmmm, are you logged in as an admin on your computer?
    – deadlydog
    Apr 14, 2016 at 2:53
3

For me, every solution had some major drawbacks. The only good way I came about is to hack around in the registry. You might want to read my post about this issue (http://daniellang.net/always-run-visual-studio-as-administrator-in-windows-8/) or just fix it directly:

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 will make VS launch as admin.

1
  • For some reason this didn't work for me, but adding the entry in HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers instead did the trick. Sep 25, 2013 at 17:44
1

On my Win8 machine with VS Express 2013 the problem is occuring when I store my project in My Documents. I've seen this on Win7 machines with older VS as well. When i create a new project / move it to a different location (like C:/Programming/) it works as it should!

0

A solution a colleague told me about was to create Task Scheduler tasks for each of your solutions. The task launches Visual Studio with a command-line that loads your project.

Here are the values you must set:

  • Give it a task name that reflects the project being opened (you'll use this later)
  • Run with highest privileges
  • Run only when user is logged on
  • Create an action:
    • action: Start a program
    • program/script: "C:\Program Files (x86)\Microsoft Visual Studio [xx].0\Common7\IDE\devenv.exe" (replace [xx] with your version of VS)
    • Arguments: /Project "[full path to your solution].sln"
  • Conditions:
    • Uncheck all items
  • Settings:
    • Check Allow task to be run on demand
    • Uncheck all other items
    • Task running rule: Do not start a new instance (optional)

OK, now you can test this by right-clicking on the task and running it. If it works great then create a shortcut to the task somewhere.

Right-click where you want the shortcut and select Create Shortcut. Here is the command line to put in the shortcut:

C:\Windows\System32\schtasks.exe /run /tn "[Task name from above]"

Now you can double-click on the shortcut to run your solution as admin without triggering the UAC.

Edit: After I wrote the above I found an article on tomssl.com which provides a more flexible solution (doesn't require creating a task for every solution). It's more involved to set up initially, but easier to use in the long run.

Always run Visual Studio as Administrator with no UAC prompt

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .