[英]How do I add a default Run As Administrator when I open a sln file from the command prompt or Windows 7/8 Jump List menu?
I have been researching around the web trying to figure out how to add Run As Administrator as the default menu item for a Visual Studio solution when you: 我一直在研究网络,试图找出如何在以下情况下将Run As Administrator添加为Visual Studio解决方案的默认菜单项:
The instructions that I have found so far: 到目前为止我发现的说明:
http://www.howtogeek.com/howto/windows-vista/add-run-as-administrator-to-any-file-type-in-windows-vista/ http://www.howtogeek.com/howto/windows-vista/add-run-as-administrator-to-any-file-type-in-windows-vista/
show how to easily add the Run As Administrator menu item to an existing file type. 显示如何轻松地将“以管理员身份运行”菜单项添加到现有文件类型。 You just have to find the right registry keys for the Visual Studio version that you're working with.
您只需要为您正在使用的Visual Studio版本找到正确的注册表项。 For example, Visual Studio 2013's registry key for its solution file type is:
例如,Visual Studio 2013的解决方案文件类型的注册表项是:
[HKEY_CLASSES_ROOT\\VisualStudio.sln.12.0] [HKEY_CLASSES_ROOT \\ VisualStudio.sln.12.0]
Then you just copy the Open command under the shell key, then paste it in as a new key whose name is runas. 然后,您只需复制shell键下的Open命令,然后将其粘贴为名称为runas的新键。
After that change, when you right-click on the solution in Windows Explorer, Run As Administrator is in the list of commands. 更改后,在Windows资源管理器中右键单击解决方案时,“以管理员身份运行”位于命令列表中。 But it is not the default.
但它不是默认值。
To open the solution as Administrator from the Jump List menu, when you right-click on Visual Studio as a pinned icon, you have to right-click on the solution file in the Jump List, then select Run As Administrator. 要从“跳转列表”菜单中以管理员身份打开解决方案,请在右键单击Visual Studio作为固定图标时,必须右键单击“跳转列表”中的解决方案文件,然后选择“以管理员身份运行”。
But I couldn't find anywhere about how to make the Run As Administrator the default command in this menu. 但我找不到任何关于如何在此菜单中将Run As Administrator作为默认命令。
So how do you do that? 那你怎么做的?
Easiest way is doing this (Works on Windows 10): Right click visual studio 2017 and open file location. 最简单的方法是这样做(在Windows 10上工作):右键单击visual studio 2017并打开文件位置。 (If it's the shortcut, right click then click properties. On the bottom click on "Open File Location")
(如果是快捷方式,请右键单击然后单击属性。在底部单击“打开文件位置”)
This should lead you to devenv.exe. 这应该会引导你到devenv.exe。
Right click this and select troubleshoot compatiblity. 右键单击此选项并选择对兼容性进行故障排除。 Select troubleshoot program and check off the box for "The program requires additional permissions" and select next.
选择“排除程序故障”并选中“程序需要其他权限”框并选择下一步。
Now if you open visual studio from where ever, it'll open it as an administrator. 现在,如果您从哪里打开visual studio,它将以管理员身份打开它。
It actually turns out to be one additional registry entry that needs to be set. 它实际上是一个需要设置的额外注册表项。 In the shell key under the file type, change the value of (Default) to be the same name as the command in the registry under the shell folder.
在文件类型下的shell键中,将(Default)的值更改为与shell文件夹下的注册表中的命令相同的名称。
For example, to set Run As Administrator to be the default, you would set the value of (Default) in HKEY_CLASSES_ROOT\\VisualStudio.sln.12.0\\shell to be runas. 例如,要将Run As Administrator设置为默认值,可以将HKEY_CLASSES_ROOT \\ VisualStudio.sln.12.0 \\ shell中的(默认)值设置为runas。
When exported, this setting looks like this: 导出时,此设置如下所示:
[HKEY_CLASSES_ROOT\VisualStudio.sln.12.0\shell]
@="runas"
Now when you right-click the solution in Windows Explorer, or when you right-click the solution after right-clicking to bring up the Jump List on the Visual Studio 2013 pinned icon, Run As Administrator is the default command instead of Open. 现在,当您在Windows资源管理器中右键单击解决方案时,或右键单击右键单击解决方案以在Visual Studio 2013固定图标上显示跳转列表后,“以管理员身份运行”是默认命令而不是“打开”。
So you can confidently open the solution itself from Windows Explorer or the Jump List menu and watch as Visual Studio opens as Administrator. 因此,您可以放心地从Windows资源管理器或“跳转列表”菜单中打开解决方案,并以管理员身份打开Visual Studio。
Updating answer for Visual Studio 2015 (under covers version "14.0"). 更新Visual Studio 2015的答案(在封面版本“14.0”下)。 Tested on on Windows 10 Pro v1703 Creators Update.
在Windows 10 Pro v1703 Creators更新上进行了测试。 Picture below illustrates the first registry change.
下图说明了第一次注册表更改。 Second change goes one better - no need to right-click the jump list item at all.
第二个更改更好 - 无需右键单击跳转列表项。
Windows Registry Editor Version 5.00
;To add "Run As Administrator" to Visual Studio 2015 Taskbar Jump List solution right-clicks
[HKEY_CLASSES_ROOT\VisualStudio.sln.14.0\shell\RunAs]
[HKEY_CLASSES_ROOT\VisualStudio.sln.14.0\shell\RunAs\command]
@="\"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\devenv.exe\" \"%1\""
;To make Jump List solutions open As Administrator by default
[HKEY_CLASSES_ROOT\VisualStudio.sln.14.0\shell]
@="runas"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.