visual-studio Visual Studio 以管理员身份运行快捷方式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4132508/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Visual Studio Run as administrator shortcut
提问by Lorenzo
how do I create a shortcut that runs Visual Studio with Administrator rights?
如何创建以管理员权限运行 Visual Studio 的快捷方式?
Actually I have to navigate to the Visual Studio start menu folder, click on the icon with the right mous button and choose "Run as Administrator".
实际上,我必须导航到 Visual Studio 开始菜单文件夹,单击鼠标右键的图标,然后选择“以管理员身份运行”。
回答by dandan78
Right-click on the shortcut, select Properties. On the Shortcut tab, click the Advanced button (bottom right). Check the Run As Administrator box.
右键单击快捷方式,选择属性。在快捷方式选项卡上,单击高级按钮(右下角)。选中以管理员身份运行框。
回答by deadlydog
I know the OP was about how to create a shortcut that runs VS as admin, but using the steps below you can just always have VS launch as admin.
我知道 OP 是关于如何创建一个以管理员身份运行 VS 的快捷方式,但是使用以下步骤,您可以始终以管理员身份启动 VS。
This is a copy of my answer to a similar post on SuperUser:
这是我对 SuperUser 上类似帖子的回答的副本:
Option 1 - Set VSLauncher.exe and DevEnv.exe to always run as admin
选项 1 - 将 VSLauncher.exe 和 DevEnv.exe 设置为始终以管理员身份运行
To have Visual Studio always run as admin when opening any .sln file:
打开任何 .sln 文件时,要让 Visual Studio 始终以管理员身份运行:
- Navigate to
C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\VSLauncher.exe. - Right-click on
VSLauncher.exeand choose Troubleshoot compatibility. - Choose Troubleshoot program.
- Check off The program requires additional permissionsand hit Next.
- Click the Test the program...button to launch VS.
- Click Next, then hit Yes, save these settings for this program, and then the closebuton.
- 导航到
C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\VSLauncher.exe。 - 右键单击
VSLauncher.exe并选择疑难解答兼容性。 - 选择疑难解答程序。
- 勾选该程序需要额外的权限并点击下一步。
- 单击“测试程序...”按钮以启动 VS。
- 单击下一步,然后单击Yes, save these settings for this program,然后单击关闭按钮。
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在直接打开Visual Studio 时始终以管理员身份运行,请对 DevEnv.exe 文件执行相同的操作。这些文件位于:
Visual Studio 2010
视觉工作室 2010
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe
Visual Studio 2012
视觉工作室 2012
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe
Visual Studio 2013
视觉工作室 2013
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe
Visual Studio 2015
视觉工作室 2015
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe
Option 2 - Use VSCommands extension for Visual Studio
选项 2 - 为 Visual Studio 使用 VSCommands 扩展
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 permissionsand click the Save button.
为 Visual Studio安装免费的VSCommands 扩展(位于Visual Studio Extensions Gallery 中),然后通过转到 Tools -> VSCommands -> Options -> IDE Enhancements -> General 将其配置为始终让 Visual Studio 以管理员权限启动并勾选Always start Visual Studio with elevated permissions并单击保存按钮。
Note:VSCommands is not currently available for VS 2015, but their site says they are working on updating it to support VS 2015.
注意:VSCommands 目前不适用于 VS 2015,但他们的网站表示他们正在努力更新它以支持 VS 2015。
My Opinion
我的看法
I prefer Option 2 because:
我更喜欢选项 2,因为:
- 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.
- 它还允许您轻松关闭此功能。
- VSCommands 带有许多其他很棒的功能,所以我总是安装它。
- 只是比选项 1 更容易做到。
回答by Leniel Maccaferri
What I was looking for was a way of running Visual Studio Solution files (.sln) as Administrator. I just found a pretty good way of doing this...
我正在寻找的是一种将 Visual Studio 解决方案文件 (.sln) 作为Administrator. 我刚刚找到了一个很好的方法来做到这一点......
Place this content inside a file named RunAsAdministrator.reg:
将此内容放在名为 的文件中RunAsAdministrator.reg:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\VisualStudio.Launcher.sln\Shell\runas\Command]
@="\"C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\VSLauncher.exe\" \"%1\""
Double click the file to execute it.
双击该文件以执行它。
Now, when you right click a file you'll have the option of running it as Adminstrator like this:
现在,当您右键单击一个文件时,您可以选择以管理员身份运行它,如下所示:


Here's the full story by the AWESOME David Ebbo: Open your solution files as admin
这是 AWESOME David Ebbo 的完整故事:以管理员身份打开您的解决方案文件
回答by ChronoPositron
- Create a shortcut to Visual Studio on your desktop
- Right-click on the program
- "Send to"
- "Desktop (create shortcut)"
- Open up properties
- Right-click on the shortcut
- "Properties"
- Within the "Shortcut" tab, click on "Advanced..." (somewhat towards bottom right)
- Select "Run as administrator" in the new window
- Apply and OK all the windows.
- 在桌面上创建 Visual Studio 的快捷方式
- 右键单击程序
- “发送至”
- “桌面(创建快捷方式)”
- 打开属性
- 右键单击快捷方式
- “特性”
- 在“快捷方式”选项卡中,单击“高级...”(有点靠近右下角)
- 在新窗口中选择“以管理员身份运行”
- 应用并确定所有窗口。
Now when you use this shortcut, it should run the program as administrator.
现在,当您使用此快捷方式时,它应该以管理员身份运行该程序。
回答by Tomer Peled
The above answers works, but on Windows 10 you might bump with disabled advanced shortcut screen. So for windows 10 do the following:
上述答案有效,但在 Windows 10 上,您可能会遇到d isabled advanced shortcut screen。因此,对于 Windows 10,请执行以下操作:
- Create shortcut to the solution file
- Right click the shortcut => properties
- Choose Shortcut tab
- Under Target add the visual studio executable location before the sln path. For example: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.exe" C:\mypath\example\example.sln
- Press Advanced under the shortcut tab - you'll be able to edit the advances window.
- Select "Run as administrator"
- Press ok
- Double click the shortcut - you should be able to run the solution as administrator now.
- 创建解决方案文件的快捷方式
- 右键单击快捷方式 => 属性
- 选择快捷方式选项卡
- 在 Target 下,在 sln 路径之前添加 Visual Studio 可执行文件位置。例如:“C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.exe” C:\mypath\example\example.sln
- 按快捷方式选项卡下的高级 - 您将能够编辑高级窗口。
- 选择“以管理员身份运行”
- 按确定
- 双击快捷方式 - 您现在应该能够以管理员身份运行解决方案。

