Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  • right-click the solution in Windows Explorer
  • right-click on a pinned application, such as Visual Studio 2013, to bring up the Jump List and then select the solution

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/

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. For example, Visual Studio 2013's registry key for its solution file type is:

[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.

After that change, when you right-click on the solution in Windows Explorer, Run As Administrator is in the list of commands. 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.

But I couldn't find anywhere about how to make the Run As Administrator the default command in this menu.

So how do you do that?

like image 464
Jeff Avatar asked Mar 26 '14 20:03

Jeff


People also ask

How do I run a SLN file as administrator?

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.

How do I make Visual Studio run as administrator by default?

On the Windows desktop, right-click the Visual Studio shortcut, and then select Properties. Select the Advanced button, and then select the Run as administrator check box. Select OK, and then select OK again.

How do I open run with administrator privileges?

Press and hold down the SHIFT key while you right-click the executable file or the icon for the application, and then select Run as. Select The following user. In the User name and Password boxes, type the administrator account and password, and then select OK.


2 Answers

Easiest way is doing this: Right click visual studio and open file location. (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.

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.

like image 139
Prasanth Louis Avatar answered Sep 28 '22 08:09

Prasanth Louis


Updating answer for Visual Studio 2015 (under covers version "14.0"). Tested on on Windows 10 Pro v1703 Creators Update. 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"

enter image description here

like image 39
SushiGuy Avatar answered Sep 28 '22 09:09

SushiGuy