Running visual studio as administrator

Running visual studio as administrator is often required, especially if you use IIS as a host for your web site. Therefore, I like it to be started as an administrator by default. So instead of right clicking it and selecting ‘run as administrator’, you can hack it a little bit so that it always starts as administrator, no matter how you start it.

Step 1: change ‘devenv.exe’ compatibility

First go to C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE, right click on ‘devenv.exe’ and select properties, click ‘compatibility tab’, check ‘Run this program as an administrator’, and click ‘OK’:

runasadmin

Step 2: hack VSLauncher.exe

You have to hack VSLauncher.exe a little, because changing its compatibility settings won’t work with visual studio 2010:

  1. Backup C:\Program Files (x86)\Common Files\microsoft shared\MSEnv\VSLauncher.exe
  2. From within a Visual Studio 2010 Tools prompt (run as admin), extract the manifest from VSLauncher.exe:
    mt -inputresource:"VSLauncher.exe" -out:VSLauncher.exe.manifest
  3. Alter the VSLauncher.exe.manifest file:

    <requestedPrivileges>
    <requestedExecutionLevel level="requireAdministrator" uiAccess="false">
    </requestedExecutionLevel>
    </requestedPrivileges>
  4. Write back the manifest into VSLauncher.exe:
    mt -outputresource:VSLauncher.exe -manifest VSLauncher.exe.manifest

If you now start visual studio by its shortcut or by opening a solution file, it will start as an administrator.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s