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

本文翻译自: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. 在Windows 7中,您可以进入程序兼容性设置并选中以始终以管理员身份运行。 Is there a similar option in Windows 8? Windows 8中是否有类似的选项?

I've always disabled UAC on my machines, and did the same after my Windows 8 upgrade, or so I thought. 我一直在我的机器上禁用UAC,并且在我的Windows 8升级之后做了同样的事情,或者我认为。 It turns out there is no off option, only turning off the notifications. 事实证明,没有off选项,只关闭通知。

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. 当我尝试调试(附加到进程,而不是F5 )时,我需要继续关闭并重新打开我的控制台\\ Visual Studio,这非常令人沮丧。

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. 真的很烦人,我需要记得采取额外的步骤以管理员的身份打开它,或者告诉它在我第一次调试时关闭并重新打开。


#1楼

参考:https://stackoom.com/question/pQdK/您是否可以强制Visual-Studio始终以Windows-中的管理员身份运行


#2楼

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. 同样,当Visual Studio固定到任务栏时,您也可以这样做。 In either location: 在任何一个位置:

  1. Right click the Visual Studio icon 右键单击Visual Studio图标
  2. Go to Properties 转到“ Properties
  3. Under the Shortcut tab select Advanced Shortcut tab下,选择Advanced
  4. Check Run as administrator 选中Run as administrator

在管理模式下设置默认操作

Unlike in Windows 7 this only works if you launch the application from the shortcut you changed. 与Windows 7不同,这仅适用于从更改的快捷方式启动应用程序的情况。 After updating both Visual Studio shortcuts it seems to also work when you open a solution file from Explorer. 更新两个Visual Studio快捷方式后,当您从资源管理器中打开解决方案文件时,它似乎也可以工作。

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. 更新警告:使用提升权限运行Visual Studio似乎是一个主要缺陷,因为资源管理器没有与它们一起运行,您也无法将文件拖放到Visual Studio中进行编辑。 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. 你也不能双击任何与Visual Studio相关的文件,并在Visual Studio中打开它(除了看起来的解决方案),因为你会收到一条错误消息,说明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. 一旦我取消选中以始终以提升的权限(使用VSCommands)开始,那么我就可以直接打开文件并将它们放入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. 大胆的更新:尽管过去没有像过去那样关闭UAC的UI,至少我看到过,你仍然可以通过注册表这样做。 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. 更改此Windows后,将提示您重新启动。 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楼

NOTE in recent VS versions (2015+) it seems this extension no longer exists/has this feature. 注意在最近的VS版本(2015+)中,似乎此扩展不再存在/具有此功能。


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) 您还可以通过Squared Infinity下载VSCommands for VS2012 ,它具有将其更改为以管理员身份运行的功能(以及其他一些很酷的部分)

在此输入图像描述

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. 可以使用Tools - > Extensions and Updates选择Online并搜索vscommands从Visual Studio菜单栏安装命令,然后根据是使用2012还是2013(或更高版本)选择VSCommands for Visual Studio 20XX并下载和安装。


#4楼

VSCommands didn't work for me and caused a problem when I installed Visual Studio 2010 aside of Visual Studio 2012. VSCommands对我不起作用,并且当我安装除Visual Studio 2012之外的Visual Studio 2010时导致问题。

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" . 转到HKEY_CURRENT_USER\\Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers并添加名为"C:\\Program Files (x86)\\Common Files\\Microsoft Shared\\MSEnv\\VSLauncher.exe""C:\\Program Files (x86)\\Common Files\\Microsoft Shared\\MSEnv\\VSLauncher.exe"和值"RUNASADMIN"

This should solve your issue. 这应该可以解决您的问题。 I've also blogged about that. 我也在博客上写过这个。


#5楼

In Windows 8 & 10, you have to right-click devenv.exe and select "Troubleshoot compatibility". 在Windows 8和10中,您必须右键单击devenv.exe并选择“疑难解答兼容性”。

  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: 如果在打开Visual Studio时它要求保存对devenv.sln的更改,请参阅此答案以禁用它:

Disable Visual Studio devenv solution save dialog 禁用Visual Studio devenv解决方案保存对话框


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 如果您改变主意并希望撤消“以管理员身份运行”兼容性设置,请在此处查看答案: 如何在Visual Studio 2015中修复无法识别的Guid格式


#6楼

  1. On Windows 8 Start Menu select All Apps 在Windows 8的“开始”菜单上,选择所有应用
  2. Right click on Visual Studio 2010 Icon 右键单击Visual Studio 2010图标
  3. Select Open File Location 选择打开文件位置
  4. Right click on Visual Studio 2010 shortcut icon 右键单击Visual Studio 2010快捷方式图标
  5. Click Advanced button 单击高级按钮
  6. Check the Run as Administrator checkbox 选中Run as Administrator复选框
  7. Click OK 单击确定
发布了0 篇原创文章 · 获赞 73 · 访问量 55万+

猜你喜欢

转载自blog.csdn.net/w36680130/article/details/105311360