Skip to content

Add “Install as…” context menu entry to windows explorer

August 12, 2011

If you’re using a restricted user account for your day to day work and only elevate to an administrator account when installing software, you probably have noticed that you cannot easily do this for MSI files.

If you’re installing from an executable (exe) file, there is an option in the context menu to run the file as a different user (Run as). This option is missing for MSI files.

One reason for this that I found on symantec’s forums is that:

Windows Installer by default doesn’t elevate to higher privileges until it is about to actually start doing work in the install sequence.

One way to elevate yourself to install MSI files is through command prompt (cmd). You’ll have to use the following command:

runas /u: "msiexec.exe /i "

Unfortunately this requires a lot of typing and it your path includes spaces it becomes a huge mess.

A more convenient way to elevate yourself for MSI installation is to add a context menu item just like for EXE files. This is done by modifying the system registry. CAUTION: before modifying the registry, make sure to make backups.

To add the context menu entry, you need to add the following key (don’t copy paste, read on why):

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Msi.Package\shell\runas\command]
@="%SystemRoot%\System32\msiexec.exe" /i "%1" %*

The @ refers to the (Default) entry.

If you try to do this manually, you will notice that the (Default) value has REG_SZ type, however for this to work the type needs to be REG_EXPAND_SZ. It is not possible to achieve this through regedit.

You will have to import the settings into the registry from a .reg file. Here’s what it should contain:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Msi.Package\shell\runas\command]
@=hex(2):22,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,\
00,25,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6d,00,\
73,00,69,00,65,00,78,00,65,00,63,00,2e,00,65,00,78,00,65,00,22,00,20,00,2f,\
00,69,00,20,00,22,00,25,00,31,00,22,00,20,00,25,00,2a,00,00,00

You can make the file yourself or download it from here

At this point you will have a “Run as…” menu item.

You can change the displayed text by editing the (Default) value of
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Msi.Package\shell\runas]

I recommend using “Install &as…”. This will match the default “Install” action. The ampersand (&) makes the menu entry responsive to Alt commands (Alt+A) in this case.

You can also change the order in which the items are listed by editing the (Default) value of
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Msi.Package\shell]

I listed “Install as…” as the second item by inserting “runas” right after “Open”
Open,runas,Repair,Uninstall

Advertisements

From → Windows

Leave a Comment

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

%d bloggers like this: