Cannot run msiexec command from PowerShell

This topic contains 4 replies, has 4 voices, and was last updated by Profile photo of arobsSs arobsSs 10 months, 1 week ago.

  • Author
  • #33104
    Profile photo of arobsSs


    I am trying to run a command from PowerShell and it does not work, the result being only a Windows Installer window which explains the parameters of the command.
    However, the same line does work when I run it from CMD.

    The command that I've been trying to run from PowerShell is the following:

    msiexec /a Application.msi /qn TARGETDIR="C:\Users\UserName\Desktop\Folder"

    First I thought that this is somehow related to permissions, but I am running PowerShell as admin and I've changed the ExecutionPolicy to unrestricted and the command still isn't working. I have also tried to run this from a batch file without any luck.

    Do you have any suggestion for making this running from PS?


  • #33105
    Profile photo of Flynn Bundy
    Flynn Bundy

    Hey mate,

    take a look into the Help for Start-Process. More so the examples to see how you can use this.

    Start-Process \filename.msi


    & \filename.msi

    Either or should work fine. Also if you want to pass arguments to your .msi you can so do something along the lines of:

    Start-Process '\filename.msi' -ArgumentList 'Args here'

    let us know how you go.

  • #33106
    Profile photo of Dave Wyatt
    Dave Wyatt

    Strange. I don't see anything wrong with your command, and I've successfully used msiexec from PowerShell.

    Just for giggles, try retyping the command; no copy and paste. Maybe there's some unprintable character in your command that's goofing things up.

  • #33108
    Profile photo of Dan Potter
    Dan Potter

    Here's an old example of how I've done it in the past.

    $execute = "msiexec.exe"

    $parameters = ' /i "e:\apps\QuestChangeAuditorAgent5(x64).msi" /qb INSTALLDIR="E:\Program Files\Quest Software\ChangeAuditor\" INSTALLATION_NAME_VALID=1 INSTALLATION_NAME="DEFAULT" REBOOT="ReallySuppress" ALLUSERS=1 STAGINGPATH="C:\Windows\TEMP\"'

    $process= [System.Diagnostics.Process]::Start($execute,$parameters)


  • #33116
    Profile photo of arobsSs

    Hello guys!

    Thank you very much for the help! Now I've managed to run the command.

    It seems that I had an extra space in the naming of the folder used as TARGETDIR. Unlike CMD, PowerShell did interpret it wrong, although the path was inside
    quotation marks.

    In other words, the command that I've used was something like:
    msiexec /a Application.msi /qn TARGETDIR="C:\Users\UserName\Desktop\Folder Name"

    Thanks again!

You must be logged in to reply to this topic.