Sean Killeen bio photo

Sean Killeen

Just a guy trying to get better at writing bios.

Email Twitter Facebook Google+ LinkedIn Instagram Github Stackoverflow Foursquare
Edit this page | Issue? Question?

Problem

I want to run several installation programs in order, and don’t want them to step on each other.

I want to avoid errors such as “another setup program is already running” which result in the second install not completing.

Solution

For files without arguments, run:

$var1 = Start-Process -FilePath "[path]" -passthru
$var1.WaitForExit()

For files with arguments, run:

$var1 = Start-Process -FilePath "[path]" -ArgumentList "[Args]" -passthru
$var1.WaitForExit()

In these examples, [path] is the full path to the file (e.g. C:\SomeFolder\MyProgram.exe) you want to run. [Args] is whatever you’d normally put after the path to the exe in the command line.

NOTE: Single quotes around the file path will ensure the command will not break if it includes a space in the path.

References