24

From this article : How to Run Visual Studio as Administrator by default

and Can you force Visual Studio to always run as an Administrator in Windows 8?

and Visual Studio Version Selector Doesn't open

I try to set devenv.exe and VSLauncher.exe to always run as admin


Yes, when I open by shortcut -> it works!

enter image description here

result...

enter image description here


Or open project&solution directly -> it works!

enter image description here

result...

enter image description here


########################## Question ##########################

But when I open by recent project&solution shortcut -> it doesn't work !

enter image description here

result...

enter image description here

Can someone help or explain please?

P.S. Window 8.1 Pro 64-bit (6.3,Build 9600) | Visual Studio Professional 2015

Community
  • 1
  • 1
  • Duplicate of [this superuser.com question](http://superuser.com/questions/482368/make-jumplist-shortcut-always-run-application-as-administrator). – Hans Passant Dec 19 '15 at 11:15
  • not all duplicate sir ! –  Dec 21 '15 at 02:53
  • 1
    Yet another and somewhat less convoluted solution to this problem can be found at http://superuser.com/q/583682/51005 – Saul Mar 23 '16 at 11:47
  • Windows 10 and Visual Studio 2017 => https://stackoverflow.com/a/42724159/2008111 – caramba Oct 26 '18 at 11:04

7 Answers7

40

I ran the troubleshoot compatibility option.

Step 1: Go to C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE. Right click on devenv.exe and select "Troubleshoot compatibility"
Step 2: Select "This program requires additional permissions"
Step 3: Test and click on next.

Everything will be working smoothly now.

Note: Don't forget to save the settings.

enter image description here

Shubham Agarwal
  • 401
  • 4
  • 5
32

You need to add string value to HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\ with name of full path to devenv.exe and value RUNASADMIN.

For my system path was: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe.

And this: C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\VSLauncher.exe for solve this problem.

You can do it in regedit or use console command (run with admin right's):

for Visual Studio IDE

REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe" /t REG_SZ /d RUNASADMIN

for Visual Studio Version Selector ( Recomment by TooN DinDarkDevil )

REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v "C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\VSLauncher.exe" /t REG_SZ /d RUNASADMIN

Here how it should look in registry editor after key adding: regedit windows after key adding

After that all projects will be open with admin rights.

It worked for me on Window 8.1 Pro 64-bit | Visual Studio Enterprise 2015

Additional information. TooN DinDarkDevil

"Microsoft Visual Studio Version Selector" when your window have installed multi version of "Visual Studio" .Visual Studio Project&Solution default openning is "Visual Studio Version Selector".

This work for me now (include recent shortcut) .

enter image description here

result..

  1. Open by pin of "Visual Studio 2015" ( work ) enter image description here


2. Open by recent of "Visual Studio 2015" ( work ) enter image description here


3. Open by pin of "Visual Studio Version Selector" ( work ) enter image description here


4. Open by recent of "Visual Studio Version Selector" ( work ) enter image description here


P.S. try it your self !!

caramba
  • 21,963
  • 19
  • 86
  • 127
Andrey Tretyak
  • 3,043
  • 2
  • 20
  • 33
  • Thank you! for your suggest. Cause your suggest then i founded answer of my problem. –  Dec 21 '15 at 02:48
  • Then will you approve my edit request. I will give you to my answer ( you will get reward ). –  Dec 21 '15 at 02:55
  • Sure, thanks a lot for adding info, it's was also useful for me. – Andrey Tretyak Dec 21 '15 at 03:07
  • @ToonDinDarkDevil from your screenshot of **regedit** l saw that you've added to registry `C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE` but not `C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe` may be that's the reason why it's not worked for you with Visual Studio pin? – Andrey Tretyak Dec 21 '15 at 03:22
  • 1
    This works in Windows 10 also, where the troubleshoot compatibility answer does not (when right clicking on devenv.exe in Windows 10, there is no "Troubleshoot compatibility" option). P.S. how the F*** did you figure this out? :) – AZ Chad Jul 26 '16 at 16:47
  • 1
    For me, on Windows 10, the "Troubleshoot compatibility" option worked just fine, plus it was not so much work. – Svein Terje Gaup Feb 28 '19 at 06:47
  • It works for me on Windows 10, vstudio 2019, although I did it through the "Troubleshoot compatibility" option, with the same result. Good to have this answer, and know what is happening "under water". – Bob Lokerse Aug 22 '19 at 16:27
11

You can force devenv.exe to always run as administrator using the compatibility checker wizard.

Open explorer and go to C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE. Right click on devenv.exe and select "Troubleshoot compatibility":

enter image description here

On the first page of the wizard, select "Troubleshoot program". Check "The program requires additional permissions":

enter image description here

Click Next, then test the program and go next to save the settings.

From now on, every time Windows runs devenv.exe (Visual Studio), it will run it as admin and you will get a UAC prompt. I tested this from the jump list and it worked as expected.

To undo this, just go through the wizard again and uncheck the "...additional permissions" checkbox.

Michael Braude
  • 6,913
  • 1
  • 22
  • 20
5

For win10 and Visual Studio 2017
You have to add a string key to registry.

Run Command Prompt as Admin and then run the following command:

REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.exe" /t REG_SZ /d RUNASADMIN
Mohammad Dayyan
  • 21,578
  • 41
  • 164
  • 232
Meysam Chegini
  • 942
  • 12
  • 12
1

Hi i ran the "toubleshoot compatibity" option over the devenv.exe and that fix this issues to me. My UAC configuration setting is the default.Same windows version

Byron
  • 301
  • 5
  • 21
1

Add the below to registry changes, update the path to vslauncher appropriately. It will add menu option Run as administrator to the solution files. Then you can right click a solution file to open it using elevated Visual Studio. But this won't work with solutions pinned to taskbar.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\VisualStudio.Launcher.sln\Shell\runas\Command]
@="\"C:\\Program Files (x86)\\Common Files\\Microsoft Shared\\MSEnv\\VSLauncher.exe\" \"%1\""

Adding screenshot (this is with Visual Studio 2015, Windows 10): 'Run as administrator' option on solution files

Abhijit Annaldas
  • 669
  • 4
  • 12
1
  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
Simas Joneliunas
  • 2,890
  • 20
  • 28
  • 35
Mr Million
  • 21
  • 1