Always start Visual Studio as an Administrator on Windows 8

37

20

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?

Boomerangertanger

Posted 2012-08-17T15:45:09.180

Reputation: 495

1Using unreleased software on an unreleased platform...you are probably going to have to put up with some nonsense. – Adam King – 2012-08-17T15:49:27.697

It's on MSDN now. – Boomerangertanger – 2012-08-17T15:51:35.650

Have you tried creating a shortcut and assign run as user to that shortcut? – tumchaaditya – 2012-08-17T15:58:26.030

Unfortunately, I need it to work when clicking on associated file types. – Boomerangertanger – 2012-08-17T16:10:04.277

The default behavior of Visual Studio is to always run as an administrator. If your user account does not have administrator priviliages, you need to escalate your user account, by using the "run as administrator" – Ramhound – 2012-08-17T16:37:52.077

1The default is to run not as an admin. – Boomerangertanger – 2012-08-17T16:39:32.660

Answers

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.

David P

Posted 2012-08-17T15:45:09.180

Reputation: 394

3Do 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. – None – 2012-08-25T01:21:18.407

1I 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. – None – 2012-08-25T01:28:04.933

9This 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. – nathanchere – 2012-08-30T00:41:14.580

@simbolo before using VSCommands I used the above solution on both the start screen shortcut and my pinned taskbar shortcut. When both of those were set to run as admin then double clicking my solutions/projects in Explorer would open in an admin level Visual Studio. I'm not sure if there's anything else I changed to make that happen but it's worth a try. If that doesn't work then see my answer for my final solution to all this. – Brian Surowiec – 2012-09-06T06:28:55.960

4FerretallicA's answer is the right one. – Jason Kleban – 2013-01-24T23:16:04.593

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 – BritishDeveloper – 2013-03-02T10:59:24.247

51

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

nathanchere

Posted 2012-08-17T15:45:09.180

Reputation: 2 236

2This Troubleshoot Compatibility is the way to go - takes care of all your shortcuts and pinned items at once! This should be the marked answer. – Jason Kleban – 2013-01-24T23:14:58.013

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.

Artem Govorov

Posted 2012-08-17T15:45:09.180

Reputation: 161

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.

Brian Surowiec

Posted 2012-08-17T15:45:09.180

Reputation: 275

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 – Boomerangertanger – 2012-09-06T07:47:33.043

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. – Brian Surowiec – 2012-09-06T08:07:23.793

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. – Boomerangertanger – 2012-09-06T11:52:29.663

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.

deadlydog

Posted 2012-08-17T15:45:09.180

Reputation: 696

http://vscommands.squaredinfinity.com/ doesn't seem to be available for VS 2015. – Naomi – 2016-04-13T16:46:08.563

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 – 2016-04-13T17:45:41.793

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 – 2016-04-13T21:42:03.440

@Naomi hmmm, are you logged in as an admin on your computer? – deadlydog – 2016-04-14T02:53:05.517

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.

Daniel Lang

Posted 2012-08-17T15:45:09.180

Reputation: 545

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. – Piotr Szmyd – 2013-09-25T17:44:00.843

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!

Tobias Wetterskog

Posted 2012-08-17T15:45:09.180

Reputation: 11

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

Scott Gartner

Posted 2012-08-17T15:45:09.180

Reputation: 201