I would like to run Visual Studio 2017/2019 as admin when I select a project from the recent list in the taskbar, ie. when opening a project via Explorer/Shell
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. It was only looking at HKCU. So I set both. But for other users that login, HKLM should come in handy.
Also included is setting the same value for VSLauncher.exe, which solves other issues.
This takes care of both VS2017 and 2019. If you only have one of them installed, remove the lines for the other.
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.
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:
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"