[英]VS2017 / VS 2019 Run As Admin from Recent solutions list
I would like to run Visual Studio 2017/2019 as admin when I select a project from the recent list in the taskbar , ie.当我从任务栏中的最近列表中选择一个项目时,我想以管理员身份运行 Visual Studio 2017/2019,即。 when opening a project via Explorer/Shell shortcuts.
通过资源管理器/外壳快捷方式打开项目时。
I did use the setting: properties -> shortcut -> advanced -> run as admin checkbox.我确实使用了设置:属性 -> 快捷方式 -> 高级 -> 以管理员身份运行复选框。
Unfortunately, this does not result in devenv running as Administrator.不幸的是,这不会导致 devenv 以管理员身份运行。
Any ideas on how to fix this?有想法该怎么解决这个吗?
The effect of the steps in Steve's answer is the addition of a single registry value.史蒂夫回答中的步骤的效果是添加了一个注册表值。 You can avoid all those steps by just adding that registry value via the command line.
您只需通过命令行添加该注册表值即可避免所有这些步骤。 For some reason I found it takes a little while to take effect, but a logout/login should make it take effect immediately.
出于某种原因,我发现它需要一段时间才能生效,但是注销/登录应该会立即生效。
For some odd reason, I found that, in my case, Windows wasn't checking HKLM.出于某种奇怪的原因,我发现,就我而言,Windows 没有检查 HKLM。 It was only looking at HKCU.
它只是看着HKCU。 So I set both.
所以我设置了两个。 But for other users that login, HKLM should come in handy.
但是对于其他登录的用户,HKLM 应该会派上用场。
Also included is setting the same value for VSLauncher.exe, which solves other issues.还包括为 VSLauncher.exe 设置相同的值,这解决了其他问题。
This takes care of both VS2017 and 2019. If you only have one of them installed, remove the lines for the other.这会处理 VS2017 和 2019。如果您只安装了其中一个,请删除另一个的行。
Also, if you changed the folder that VS gets installed to, then change the path to devenv.exe
, or just use Steve's answer to do it the other way.此外,如果您更改了 VS 安装到的文件夹,请更改
devenv.exe
的路径,或者仅使用 Steve 的回答以另一种方式执行此操作。
In an administrator command prompt:在管理员命令提示符中:
reg.exe Add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\devenv.exe" /d "^ RUNASADMIN"
reg.exe Add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\devenv.exe" /d "^ RUNASADMIN"
reg.exe Add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v "C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\VSLauncher.exe" /d "^ RUNASADMIN"
reg.exe Add "HKCU\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\devenv.exe" /d "^ RUNASADMIN"
reg.exe Add "HKCU\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\devenv.exe" /d "^ RUNASADMIN"
reg.exe Add "HKCU\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v "C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\VSLauncher.exe" /d "^ RUNASADMIN"
Or, if you prefer a .reg file:或者,如果您更喜欢 .reg 文件:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]
"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Professional\\Common7\\IDE\\devenv.exe"="^ RUNASADMIN"
"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Professional\\Common7\\IDE\\devenv.exe"="^ RUNASADMIN"
"C:\\Program Files (x86)\\Common Files\\Microsoft Shared\\MSEnv\\VSLauncher.exe"="^ RUNASADMIN"
[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]
"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Professional\\Common7\\IDE\\devenv.exe"="^ RUNASADMIN"
"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Professional\\Common7\\IDE\\devenv.exe"="^ RUNASADMIN"
"C:\\Program Files (x86)\\Common Files\\Microsoft Shared\\MSEnv\\VSLauncher.exe"="^ RUNASADMIN"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.