3

I require the file

C:\Program Files (x86)\Common Files\microsoft shared\MSEnv\VSLauncher.exe 

to automatically run as administrator, otherwise I cannot open *.sln files from Windows Explorer.

I had addressed this problem previously by checking the "Run as Administrator" check-box in the file property's compatibility tab, however this no longer works. Opening VSLauncher.exe directly does nothing, but right clicking it and selecting "Run as Administrator" does! All my devenv.exe are set to run as admin and they work as expected.

It's worth noting that this broke after some updates, possibly Visual Studio 2010 Service Pack 1.

studiohack
  • 13,477

1 Answers1

3

From Getting Visual Studio 2010 SP1 to run elevated when launching .sln files :

After some research, I found that the reason for Windows ignoring my compatibility setting was that VSLauncher.exe now had a manifest embedded, which contained the following fragment:

<requestedPrivileges>
   <requestedExecutionLevel level="asInvoker" uiAccess="false">
   </requestedExecutionLevel>
</requestedPrivileges>

So, VSLauncher.exe now specified that it always wanted to be run at the same execution level as its invoker. And, since of course the program must know better than the user, this caused Windows to ignore my own execution level setting.

And now, to the solution. Since Windows wouldn’t let me override what the program said it wanted, I needed to override what the program said it wanted.

To do that, I used the Manifest Tool that comes with the Windows SDK (and thus with Visual Studio):

mt -inputresource:"VSLauncher.exe" -out:VSLauncher.exe.manifest

This command extracted the manifest from VSLauncher.exe into a file called VSLauncher.exe.manifest. I then edited the manifest to request the desired execution level:

<requestedPrivileges>
   <requestedExecutionLevel level="requireAdministrator" uiAccess="false">
   </requestedExecutionLevel>
</requestedPrivileges>

Then, I could write back the manifest:

mt -outputresource:VSLauncher.exe -manifest VSLauncher.exe.manifest

With the desired result.

One note of caution: Please make a backup copy of VSLauncher.exe before manipulating the manifest.
And perform at your own risk.

harrymc
  • 498,455