Run an MSI with PSExec

Run an MSI with PSExec

Run an MSI with PSExec remotely is very simple, but most of the times people forget that we need to launc msiexec.exe in order to actually run the .msi.
In order to remotely run an MSI with PSExec, located in a share, you would need to run the following command:

PsExec.exe \\TargetComputer -d -s cmd /c "msiexec.exe /I "\\Share\repository\mymsi.msi" /quiet /norestart"

So in the example above we have the following:

  • \\TargetComputer is obviously the remote machine where you want the MSI to run on.
  • -d can be avoided, but I like it as it won’t need to wait for the process to finish to keep using my cmd session. As per psexec’s help: Don’t wait for process to terminate (non-interactive).
  • -s: Run the remote process in the System account.
  • Cmd /c “command in quotes” will run a command prompt on the remote machine that will execute what’s contained in quotes “”.
  • msiexec.exe /I “\\Share\repository\mymsi.msi” /quiet /norestart will run the MSI. It first calls msiexec to run the MSI with /I option (normal installation). It then needs the package name (full path to the file in the share), this one is also in quotes in case it has spaces. /Quiet and /norestart are MSI dependent and it depends if the MSI has got these options or not.

If you have an MSI with no switches required and you want to wait for the process to terminate, run this:

PsExec.exe \\TargetComputer -s cmd /c "msiexec.exe /I "\\Share\repository\mymsi.msi""

Practical example (Install LAPS x64 remotely)

Let’s say you want to install LAPS on LAPSSRV01 and the application (MSI) is located here:
\\lapsdc01\LAPS_REPOSITORY$\LAPS.x64.msi

You will need to run the following:

Psexec.exe \\lapssrv01 -d -s cmd /c "msiexec.exe /I "\\lapsdc01\LAPS_REPOSITORY$\LAPS.x64.msi" /quiet /norestart"

Run an MSI with PSExec

This will install LAPS x64 on the target machine.

IT Droplets

IT Droplets