Notification texts go here Contact Us Buy Now!

Make msiexec wait until the installation completes

In this post, we'll explore two methods to make msiexec wait until the installation completes. Let's dive in.

Method 1: Using Start-Job and Wait-Job

You can use the following PowerShell commands to achieve this:

$myJob = Start-Job {[your msiexec call]} Wait-Job $myJob

This approach involves starting the msiexec installation as a job using Start-Job and then waiting for the job to complete using Wait-Job.

Method 2: Using Start-Process and WaitForExit

Alternatively, you can use the following PowerShell commands:

$params = @{ "FilePath" = "$Env:SystemRoot\system32\msiexec.exe" "ArgumentList" = @( "/x" "$($productCodeGUID)" "/qn" "REMOVE=ALL" "/norestart" ) "Verb" = "runas" "PassThru" = $true } $uninstaller = start-process @params $uninstaller.WaitForExit()

This approach involves starting the msiexec installation as a process using Start-Process and then waiting for the process to complete using WaitForExit.

You can tweak the params to match your specific needs.

Choosing the Right Approach

Whether you choose to use the Start-Job and Wait-Job approach or the Start-Process and WaitForExit approach depends on your specific requirements. If you need more control over the installation process or require asynchronous execution, the Start-Job and Wait-Job approach might be a better fit. Otherwise, the Start-Process and WaitForExit approach is a simpler and straightforward option.

Additional Option: Using Start with the /wait Switch

You can also use the 'start' command with the /wait switch to achieve the same result:

start /wait msiexec -passive -i package.msi

This approach is similar to using Start-Process, but it uses the native 'start' command available in Windows.

Ultimately, the choice of approach depends on your specific needs and preferences. Experiment with each method to find the one that works best for your scenario.

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.