VS2017 / VS 2019 Run As Admin from taskbar

后端 未结 2 1171
礼貌的吻别
礼貌的吻别 2021-01-30 03:10

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

相关标签:
2条回答
  • 2021-01-30 03:32

    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"
    
    0 讨论(0)
  • 2021-01-30 03:37
    1. Close all instances of Visual Studio
    2. Right click on the Visual Studio 2017/2019 icon in your task bar
    3. Right click on Visual Studio 2017/2019 and click Properties
    4. Click open File Location button
    5. Right-click devenv.exe file in that folder appears
    6. Select Troubleshoot compatibility
    7. Select Troubleshoot program
    8. Select The program requires additional permissions
    9. Click Test the program and wait for the program to launch
    10. Then click Next button
    11. Select Yes, save these settings for this program
    12. Click Close
    13. Reopen your project from recent list
    0 讨论(0)
提交回复
热议问题