Visual Studio “Run As Administrator” Only From Shortcut


Last week I had to re-install Windows. I haven’t done it in a while, so, had to remember all those “1 time” tips I do after reinstall. For example, downloading SQL Server Developer Edition before Visual Studio to get the full Management Studio. Another example, setting Visual Studio to pin to the Start menu, and configuring it for UAC.

The Problem

In the very first year of Windows 7, I used to have many problems with UAC on and always disabled it, later, things started to get better and it became my normal config to leave it on. One problem that remained is that if you have a program set to always “Run AS Administrator”, if this program has associated files (can open files with certain extensions if you click the files), you no longer can open those files directly.

So, like many, I do pin visual studio to the Start menu


I also need to set it to “Run As Administrator” in so many times (for stuff with built-in IIS, not much is on IIS Express).

I right click the shortcut, go to “Compatibility” tab, and check “Run this program as an administrator”.


Note that this if done with any shortcut to Visual Studio devenv.exe file, has the same effect of doing it on the EXE directly, which is making the EXE require Admin permissions whenever run.


The problem is, when I do that, clicking any .CS or .SLN file doesn’t work in Visual Studio…


So, I had either the option to remember to open Visual Studio as Administrator when required (and restart it if open without Admin privileges) or I have to open files only from Start menu shortcuts and pinned shortcuts and VS File –> Open


Both are bad, because it’s very common for me to work on projects when I’m confortable with having VS run as admin, and many times also I get source code from the Internet and I just want to click an SLN file in Windows Explorer or even a CS file inside zip/rar file and quickly browse the code in the solution / file.


The Solution

One thing I discovered later, is that you can actually set only a shortcut to open the EXE as administrator, so that other shortcuts and the System itself opening the EXE will not require that permission.


So, how can you do that? I right click the shortcut, choose “Properties” as usual, but this time I go to another tab, “Shortcut”, then click “Advanced”, and then check the OTHER “Run as administrator” checkbox:



The plan is simple. I apply this to the shortcut pinned to the Start menu and the task bar, so, whenever I click any of those, I get Visual Studio running as Administrator, but, when I open a file from Windows Explorer or Zip/Rar file, I do NOT run VS as Administrator (because as mentioned above, it won’t work anyway).



This is not much of a very secret trick or something, but I’m trying to get back to blogging more and more by writing anything that comes to my head like this one. You ideas are always welcome either on this one or on other topics you might want me to blog about.



Share With Friends:

P.S. Please help me out by checking this offer, then look below for a small Thank You.

How did I learn that?

As a bonus for coming here, I'm giving away a free newsletter for web developers that you can sign up for from here.
It's not an anything-and-everything link list. It's thoughtfully collected picks of articles and tools, that focus on Angular 2, ASP.NET 5, and other fullstack developer goodies.