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,490
  • 1
    Is "Run as Administrator" set for all users or just you? – wullxz May 17 '11 at 06:47
  • I think, why can't you open .sln files without admin permissions ist the more interesting question. Maybe this can be solved more easy. – Michael K May 17 '11 at 07:06
  • @Michael - Normally I would agree, but in this case, it is Visual Studio he is talking about. There are many cases where VS has to be opened with admin privileges during development. – Jared Harley May 17 '11 at 07:13
  • This has been discussed before, but not specifically dealing with VS2010 SP1. – Jared Harley May 17 '11 at 07:14
  • This behavior seems kinda strange to me, I'm using vs2010 on win7 x64 pro since it was released and I don't have any problem like this. To work around the problem, is there a way to start vs as admin via batch file? – Michael K May 17 '11 at 07:16
  • wullxz: I have tried setting it both ways (for all users and just me.) – Evil Pigeon May 18 '11 at 09:09
  • Jared, I have applied this exact solution previously, it doesn't seem to work any more. The SP1 install could just be a coincidence. It feels like a broken registry setting, as if the "Run as Administrator" check-box does nothing. Selecting Run as administrator from the context menu works as expected though. Really bizarre. – Evil Pigeon May 18 '11 at 09:20
  • I'm seeing this exact behavior, and it seemed to be post-VS2010-SP1 for me as well. VS2010 .sln files open fine, althoughVSLauncher does take it's time about opening them. VS2005.sln` files do nothing at all (a quick spin of the wait cursor if you're lucky). I have all devenv's and VSLauncher set to run as Administrator on Windows 7 x64. – julianz May 20 '11 at 00:28

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
  • 480,290