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


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

  • Select "Troubleshoot program"
  • Check "The program requires additional permissions"
  • Click "Next"
  • Click "Test the program..."
  • Wait for the program to launch
  • Click "Next"
  • Select "Yes, save these settings for this program"
  • 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


    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:

  • Right click the Visual Studio icon
  • Go to Properties
  • Under the Shortcut tab select Advanced
  • Check Run as administrator
  • 在管理员模式下设置默认操作

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


    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)

    在这里输入图像描述

    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.

    链接地址: http://www.djcxy.com/p/18398.html

    上一篇: Visual Studio的调试/加载速度非常慢

    下一篇: 您是否可以强制Visual Studio始终以Windows 8中的管理员身份运行?