0

How can I have powershell run the silent uninstall first, wait until it is finished, and then run the install? After researching I did as below, which works, but the blank Notepad window pops up and I had to close it.

I don't want the user to get any notepad window when I deploy this to them, simply uninstall and then install.

Get-WmiObject -Class Win32_Product | Where-Object {$_.Name -eq "On-Screen Takeoff"} | foreach-
object -process {$_.Uninstall()} 

Notepad.exe | Out-Null

$arguments="/quiet"
Start-Process "\\davisconstruction.com\ROOT\Installs\OnCenter\OST\Testverion3906\ost3906.msi" $arguments
  • What is the point of calling notepad? – MDMoore313 Sep 19 '13 at 14:16
0

I use uninstallw for this task, then I can easily

start-process  -path $Path -arguments $arguments -wait

-wait is what you're looking for, functions just like start "" /wait .... in batch does.

  • Just so I understand, I would take out Notepad.exe | Out-Null and instead I would just use -wait after my 1st script when I run the whole thing? thanks – Sagun Sep 19 '13 at 14:33
  • Yeah, I don't see what running notepad accomplishes, so I would remove it. Basically, you would run start-process -path $PathToUninstallw -arguments $UninstallwArguments -wait' for the uninstall, then another start-process` for the installer, again with -wait. – MDMoore313 Sep 19 '13 at 14:38
  • I'm all set I was able to call a batch uninstall file pause for about 30 seconds and then run the uninstall. This is thanks to some other forums and feedback from other folks. All this ran silently so I am set thank you for your feedback. Start-process "<path>" Start-Sleep -Seconds <#> $arguments="/quiet" Start-process "<path>"$arguments – Sagun Sep 20 '13 at 18:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.