简体   繁体   English

从命令提示符或Windows 7/8跳转列表菜单打开sln文件时,如何添加默认的“以管理员身份运行”?

[英]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解决方案的默认菜单项:

  • right-click the solution in Windows Explorer 在Windows资源管理器中右键单击解决方案
  • right-click on a pinned application, such as Visual Studio 2013, to bring up the Jump List and then select the solution 右键单击固定应用程序(如Visual Studio 2013)以显示跳转列表,然后选择解决方案

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.

相关问题 上下文菜单中的“以管理员身份运行”不提示输入密码,如何从命令提示符下输入密码 - “Run as Administrator” in context menu doesn't prompt for password, how do I do that from command prompt 如何在Windows命令提示符下对文件名列表进行排序? - How do I sort a list of file names in the Windows command prompt? 如何从 Windows 命令提示符开始运行 Window(Windows 键 + R)? 我还想定义 WHAT 程序 Run 应该在同一命令中打开 - How do I start Run Window (Windows key + R) from Windows Command Prompt? I also want to define WHAT program Run should open in the same command 如何在VIM中打开Windows命令提示符到活动文件的当前目录? - How do I open the windows command prompt to the current directory of the active file in VIM? 如何以管理员权限运行 Anaconda 提示符? - How do I run Anaconda prompt with administrator privileges? 如何在Windows命令提示符下添加批注? - How do I add mass comments into Windows Command prompt? 如何从 windows 命令提示符在虚拟环境中运行 python 程序? - How do I run a python program in a virtual environment from windows command prompt? 如何从 Windows 上的命令提示符更新 golang? - How do I update golang from command prompt on Windows? 如何使用命令提示符和PowerShell添加隐藏文件? - How do I add a hidden file using a command prompt and PowerShell? Windows开发人员命令提示符说我不是管理员 - Windows developer command prompt says I'm not administrator when I am
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM