Skip to content

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

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

Inspiron 14R annoyances on Natty

This is a list of annoyances I’ve discovered on the Dell Inspiron 14R running Ubuntu 11.04 (Natty Narwhal).

  • Switching display options with an external monitor attached results in a black screen with only the mouse cursor visible
  • The buttons above the keyboard do not map properly.
  • Touchpad is very sensitive, which causes accidental palm clicks
  • Turning off bluetooth through the Indicator Applet disconnects both WiFi and bluetooth. Turning it back on, leaves the radio off. You can restore connectivity by using the radio on/off switch on the keyboard (Fn+F2)

Will update as I find more things that bother me.

Ubuntu Natty Narwhal (11.04) on DELL Inspiron 14R (N4110)

Although ubuntu.com only lists Inspiron 14R working with pre-installed Ubuntu 10.10 (x86), I’ve been waiting too long to buy a new laptop, so I sucked it up and got it. There was no option to get Ubuntu pre-installed on dell.com, so I went with Windows 7 Home Premium, which will still be useful as a second OS for when things just don’t work. I happened to chip in on the “free” XBox offer for students, so my basic intel core i5 hardware configuration may differ from the regular basic, but here are all the specs:

  • 2nd Generation Intel® Core™ i5-2410M processor 2.30 GHz with Turbo Boost 2.0 up to 2.90 GHz
  • 14.0″ High Definition (720p) LED Display with TrueLife™
  • 4GB Single Channel DDR3 SDRAM at 1333MHz
  • 500GB SATA hard drive (7200RPM)
  • Intel HD Graphics/HD Graphics 3000 with up to 1.6GB Dynamic Video Memory
  • 8X Tray Load CD/DVD Burner (Dual Layer DVD+/-R Drive)
  • Intel® Centrino® Wireless-N 1030, 1×2 bgn + Bluetooth
  • 48 WHr 6-cell Lithium Ion Primary Battery
  • Integrated 1.0 mega pixel widescreen HD Webcam

Nothing fancy, but overall, I don’t think I need anything extra. I’m not planning to do any gaming and the Intel graphics card should offer best compatibility. The other option was the Nvidia Optimus card, which DOES NOT work with Ubuntu.

Naturally, I wiped the hard drive and reinstalled a fresh copy of Windows 7 followed with Ubuntu Natty Narwhal (11.04).

First, I tried installing from a flash drive, which is a breeze to set up. I could not boot Ubuntu Live when using the flash drive in the USB port on the far right. Turns out that’s the USB 3.0 port (hence the SS written next to the port). Switching ports to the one on the close left made things work properly. I did not try the eSATA/USB port, so can’t comment on whether that works.

Ubuntu live worked like a charm. There were no apparent problems and the wireless adapter functioned without a hitch.

BTW, if you plan on installing Windows to dual-boot with Ubuntu, it’s probably the best idea to pre-format your hard drive in Ubuntu live. If you let Windows 7 partition your hard drive, no matter how you select the partitions, it will create 1 additional partition for essential system files. This is not entirely necessary, but it does have its uses (take a look at the discussion here). It is mostly used for system recovery purposes where you would normally have to boot from Windows 7 DVD to fix the problems (at least that was my understanding of it). The downside to this, is that the partition will use up one of your 4 primary partitions. That’s not a huge problem with most newer operating systems (for Windows starting with Vista), since they can be installed on logical partitions. Nevertheless, I’d like to keep my options open. Preformatting the hard drive will make Windows 7 install into the partition you indicate without the additional SYSTEM partition.

I like being flexible, which means I want to use LVM for my Ubuntu installation. Unfortunately, LVM cannot be configured during the standard Ubuntu installation and I had to use the Ubuntu alternate installation CD. This does not have a nice GUI, but is fairly intuitive. The problem is that I could not get Ubuntu alternate installer to load from the flash drive, no matter what port I tried. I could get to the first menu after booting, but selecting the Install Ubuntu onto Hard Drive option did not do anything. I think this was probably the problem with Pendrivelinux.com Universal USB Installer, since they seem to generate their own boot menu. This may get fixed in the near future, but if it doesn’t, burning the ISO onto a CD and booting from that, worked fine in my case.

Ubuntu installed without a problem and I’ve been using it for the past 4 days. I haven’t had any hardware related issues yet, but I still have to test the bluetooth, hybernation (sleep works fine), and CD/DVD burning. Everything else seems to just work. The multimedia keys (screen brightness, wireless on/off, volume, etc.) are recognized and function properly. I have not toyed around with the touch pad to make it recognize multi-touch actions, but I don’t particularly care about them and wouldn’t mind if they didn’t work. Touch pad scrolling works fine though. Webcam and mic are working as well.

Setting up GRUB2 for dual-booting with Windows

There are a lot of guides and posts about doing this and in general this should be pretty automated. Here are just a couple of tweaks that I like to add to the default GRUB2 setup. These tweaks will persist through GRUB updates.

Note that after changing any of these options, you will need to run
sudo update-grub
for changes to take effect.

  1. I don’t like that Windows by default appears at the bottom of the list in Grub. The best way to alter positioning of Windows menu entry in Grub is by editing the files in the /etc/grub.d/ directory. During grub initial setup and update, grub will execute the update-grub script. This script, in turn, will go through the /etc/grub.d/ directory and execute each script in the alphabetical order. So the numerical prefix of each script tells the order in which they are executed.By default windows partitions are detected by the 30_os-prober script. So the easiest solution is to give this script a lower number prefix, by renaming it to, for instance, 08_os-prober (if you want it to appear before the linux entries, which are 10_linux) or 15_os-prober (if you want them to appear after linux entries).

    Personally, I want the Windows entry to simply state “Windows 7”. For this, you will have to create a new custom script that will generate a windows menu entry. The best way to do this is by copying the 40_custom script to a new file, for instance 08_windows. Now, you will have to copy the automatically generated windows menu entry from /boot/grub/grub.cfg and place it in the 08_windows script file, right under the comments. You can now rename the label on the first line to anything you want. It should look like this:

    menuentry "Windows 7 Professional" --class windows --class os {
    	savedefault
    	insmod part_msdos
    	insmod ntfs
    	set root='(/dev/sda,msdos2)'
    	search --no-floppy --fs-uuid --set=root 6AB615090161313C
    	chainloader +1
    }

    Finally, you will have to disable the os-prober script from generating duplicate windows entries. This is done in the /etc/default/grub file. You will need to add the following line (or edit the option if it is already present):
    GRUB_DISABLE_OS_PROBER="true"

    The down side to disabling os-prober and having a custom entry is that the menu entry will not be updated if you remove windows or change the partition that it resides on; however, you can always re-enable os-prober and update your windows menu entry manually through the same process.

  2. It is annoying to always have to remember to select the correct OS to boot to when all you want to do is restart the computer. Fortunately, GRUB2 can remember the last menu entry that you selected and chose it for you automatically the next time you reboot (it will only do this for OS entries and will not remember Memtest entries). This is enabled in /etc/default/grub file by setting the following options (these options should already be present, but perhaps not set to the right values):
    GRUB_DEFAULT=saved
    GRUB_SAVEDEFAULT=true

    Don’t put quotes around the values.

    Note that savedefault option must be present in each of the menu entries for the selection to be remembered (see the menu entry code above). This is why memtest menu entries are not remembered upon reboot.

  3. I like to see all the steps that happen while Ubuntu is booting up or shutting down. To enable this verbose mode and disable the “fancy” Ubuntu loading screen, you simply need to omit the “quiet splash” flags from the grub menu entry. You can remove them persistently in /etc/default/grub file. The entries of interest are GRUB_CMDLINE_LINUX_DEFAULT and GRUB_CMDLINE_LINUX. When update-grub script is run, it, by default, generates two entries for each kernel: default and recovery. The *_DEFAULT option applies only to the default entry and GRUB_CMDLINE_LINUX entry applies to all linux kernels. GRUB_CMDLINE_LINUX should have an empty string as its value. GRUB_CMDLINE_LINUX_DEFAULT should have “quiet splash” options, which is what you want to remove (leave the empty string).

Many more options to configure GRUB2 behavior can be found in the GRUB2 manual.

Remember to run sudo update-grub after changing the settings.