Run MSI files as administrator from a user account

19

4

I'm usually logged in as a normal user on my Windows XP box. Sometimes, when I want to install a software update, I don't want to log off and log on again as admin, but I right-click the installer exe and choose "Run as..." to run it from my admin account. However, this option only seems to exist for exe files, not for msi files.

Is there a way to make msi files run under a different account? Or is that not advisable for some reason?

Tim Pietzcker

Posted 2009-08-13T08:53:25.670

Reputation: 2 338

Just launch the install of the MSI file from an elevated command prompt (right click cmd.exe and select "run as administrator"). Install with a command line something like this: msiexec.exe /I "MyFile.msi" /QN /L*V "C:\msilog.log" (update paths as appropriate). Runas should work OK, I just find an elevated command prompt easier. – Stein Åsmul – 2017-09-07T21:14:07.233

Answers

25

.msi files can be executed with msiexec.exe, so in combination with the runas command, you could accomplish what your want:

runas /user:administrator "msiexec /i <path and filename of your msi>"

As a full-path to the file is recommended, it might need quotes around it and you need to escape them then with a backslash \:

runas /user:administrator "msiexec /i \"<path and filename of your msi>\""
                                      ^^                               ^^

fretje

Posted 2009-08-13T08:53:25.670

Reputation: 10 524

Ah thanks, hadn't checked serverfault. @fretje: Thanks, however I first got an error message that msiexec couldn't open the msi file. It appears that you need to specify the entire path to the msi file. The current directory that runas is run from doesn't get passed to the command that is being run, in this case msiexec (which makes sense). – Tim Pietzcker – 2009-08-13T09:32:57.900

It looks like you should also be able to just use msiexec /a package.msi -- see the msiexec page on TechNet (which says it's for Server 2003, but appears identical to the content of the corresponding page in the XP help system).

– SamB – 2010-12-10T22:39:06.000

@SamB: Administrative installation merely means installing an image of an installsource local on the network from where others then can install the application on their machine (in stead of using a cd-rom). The user can then choose to run-from-source when he installs and the installer uses most of the product's files directly from the network. So this is not what the OP means (run as administrator).

– fretje – 2011-05-19T07:11:01.223

@fretje: Oh... that's confusing! – SamB – 2011-05-19T15:24:40.553

6

You can always open a command prompt as an administrator (either right-click runas or start->run->runas /user:administrator cmd), change to the directory where your MSI exists, and execute msiexec /i product.msi

Or add this to your register: HKEY_CLASSES_ROOT\Msi.Package\shell\runas\command Values: Install &as... HKEY_CLASSES_ROOT\Msi.Package\shell\runas\command Value: msiexec /i "%1"

Sam

Posted 2009-08-13T08:53:25.670

Reputation: 251

0

Take a look at runas from the command line. You can launch anything under as specified account.

Richard

Posted 2009-08-13T08:53:25.670

Reputation: 8 152