在Windows 7中,你可以进入程序兼容性设置并勾选“关闭”以始终以管理员身份运行。Windows 8中也有类似的选项吗?

我总是在我的电脑上禁用UAC,在我升级Windows 8之后也是如此,至少我是这么认为的。结果是没有关闭选项,只能关闭通知。

这意味着以管理员身份运行任何内容,尽管在管理员组中。当我尝试调试(附加到进程,而不是F5)时,我需要不断关闭和重新打开我的控制台\Visual Studio,这非常令人沮丧。

这真的很烦人,我需要记住以管理员身份打开它,或者在我第一次进行调试时告诉它关闭并重新打开。


当前回答

同时,还可以检查兼容性故障处理

右键单击Visual Studio >,选择“排除兼容性问题”。 选择“故障排除程序”。 检查该程序需要额外的权限。 单击测试程序。 等待片刻,直到程序启动。单击Next。 选择Yes, save these settings for this program。 等待问题解决。 确保最终状态是固定的。单击Close。

检查详细步骤,以及在Visual Studio中始终以管理员身份打开VS的其他方法需要应用程序具有更高的权限。

其他回答

在Windows 8、Windows 10和Windows 11中,您必须右键单击devenv.exe并选择“排除兼容性问题”。

选择“故障排除程序” 勾选“该程序需要额外权限” 点击“下一步” 点击“测试程序…” 等待程序启动 点击“下一步” 选择“是,为此程序保存这些设置” 点击“关闭”

如果,当你打开Visual Studio时,它会要求将更改保存到devenv。Sln,看到这个答案禁用它:

禁用Visual Studio devenv解决方案保存对话框


如果您改变主意并希望撤消“以管理员身份运行”兼容性设置,请参阅这里的答案:如何修复Visual Studio 2015中无法识别的Guid格式

只需在program Files目录(或其他位置)中找到该程序。右键单击EXE文件,在底部的第二个选项卡上选中以管理权限强制运行该程序的复选框。 从现在开始,exe文件的所有快捷方式都将以管理权限启动:)

这些对我都没用。我总是以管理员身份启动它的方法是修改注册表。

1. Just start regedit.exe.
2. Navigate to Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
3. Right Click New->String Value
4. Add C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\devenv.exe (or the correct path for your system)
5. Right Click on this entry and select Modify.
6. Add for Value Data: ~ RUNASADMIN.

全部完成。

注意在最近的VS版本(2015+),这个扩展似乎不再存在/有这个功能。


你也可以下载VS2012的VSCommands by Squared Infinity,它有一个功能来改变它以管理员身份运行(以及其他一些很酷的小部件)

更新

你可以使用Tools->Extensions and Updates从Visual Studio菜单栏中安装命令,选择Online并搜索vscommands,然后选择vscommands for Visual Studio 20XX,这取决于是使用2012年还是2013年(或更高的版本),然后下载并安装。

我知道这有点晚了,但我只是通过修改(读作“黑客”)devenv.exe文件的清单来做到这一点。我应该先讲到这里,因为所述的解决方案似乎更简单一些,而且可能更受微软的支持。:)

我是这样做的:

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.) "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". 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. Expand the "RT_MANIFEST" node, then double-click on "1" under that. This will open up the executable's manifest in the binary editor. Find the requestedExecutionLevel tag and replace "asInvoker" with "requireAdministrator". A la: <requestedExecutionLevel level="requireAdministrator" uiAccess="false"></requestedExecutionLevel> Save the file.

您刚刚保存了添加到项目中的可执行文件的副本。现在需要备份原始文件,并将修改后的exe复制到安装目录。

正如我所说,这可能不是正确的方法,但它似乎有效。如果有人知道任何负面影响或必要的惩罚,请插话!