Im sure I must be missing something but there is no -wait switch. There is -waitformsiexec but this is just a exe with no msi inside its a standard .exe setup program.
Any tricks?
Im sure I must be missing something but there is no -wait switch. There is -waitformsiexec but this is just a exe with no msi inside its a standard .exe setup program.
Any tricks?
You can use Start-Process instead as it has -wait parameter with it.
Also, waitformsiexec will work if this .exe has .msi in it. as mentioned in help toolkit.
I haven’t checked waitformsiexec but start-process can solve this for you.
example:
Start-Process C:\Windows\System32\msiexec.exe -ArgumentList “/uninstall {GUID}” -wait
The solution to restart after an misexec.exe uninstallation is to add the /forcerestart parameter to the msiexec call instead of trying to restart in powershell
Start-Process C:\Windows\System32\msiexec.exe -ArgumentList @("/uninstall {GUID}", “/forcerestart”)
some .exe’s will make a copy of themselves into, for example, %temp% and then relaunch itself from that location and the first .exe will terminate. That can also potentially be the issue you are experiencing.
Autodesk setup’s are notorious for that, but thankfully they added a /W switch. I know there are others as well but cannot recall examples. In those situations, it gets tricky to properly wait.
I usually do something like this after execute-process and it seems to work well.
If ( (Get-Process -Name “setup”) -or (Get-Process -Name “setup123”) ) {
Write-Log “Still Installing…”
Start-Sleep -Seconds 60
}