Link to home
Start Free TrialLog in
Avatar of Robin Lemon
Robin LemonFlag for Australia

asked on

Run multiple programs from Powershell script

I need to replace a VB script with a Powershell script. The script installs the components for Microsoft Office Communicator. For example,

' Install Communicator
call WSHShell.Run ("msiexec -i communicator.msi /qb! /norestart",1,True)

' Install Latest Communicator Patch
call WSHShell.Run ("msiexec -p communicator.msp /qb! /norestart",1,True)

I am trying to do the same with Powershell using:

# Install Communicator
Invoke-Expression -Command "msiexec -i communicator.msi /qb!"

# Install Latest Communicator Patch
Invoke-Expression -Command "msiexec -p communicator.msp /qb! /norestart"

The trouble is that the second program does not wait for the first program to finish. How can I force each program to wait until the previous program has finished?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of wmeerza
wmeerza
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Robin Lemon

ASKER

I had good success with the [diagnostics.process]::start("notepad.exe").WaitForExit() method.

e.g.

# Install Communicator
[diagnostics.process]::start("msiexec.exe","-i communicator.msi /qb!").WaitForExit()

# Install Latest Communicator Patch
[diagnostics.process]::start("msiexec.exe","-p communicator.msp /qb! /norestart").WaitForExit()
excellent