So I’m popping up a user dialog (using show-installationprompt) for installing some MSI’s but only if they have some specific processes (word and excel) running. I have 2 buttons on the show-installationprompt window called “Install Now” and “Defer”. What I would like to do is have a loop checking for those processes so that if the users closes them, they don’t have to come back and hit “install now”, it would just start running automatically. Hopefully this makes sense…
Has anyone done something like this?
Here’s what I have:
If ($deploymentType -ine 'Uninstall') {
##*===============================================
##* PRE-INSTALLATION
##*===============================================
[string]$installPhase = 'Pre-Installation'
$activeProcess = Get-Process winword, excel -ErrorAction SilentlyContinue
$installType = Get-Content $dirFiles\installtype.dat -Force
If ($activeProcess -ne $null)
{ Start-Sleep -Seconds 1
If ($installType -eq “full”) { Write-Host “Commence full installation” }
Else {
$userResponse = show-installationprompt -message “nAn update needs to be installed on your computer.
nn
nYou will be required to close out of Word and Excel for this update to install.n
nnIt is not necessary to close these programs immediately. You may close them and begin at your convenience. All other programs will remain available during the update.
nn
nNOTE: Clicking Defer will install this software automatically the next time you logoff or restart your computer.” -buttonrighttext “Defer Update” -buttonlefttext “Install Now”
#Do {$userResponse} Until ($activeProcess -eq $null)
If($userResponse -eq ‘Defer Update’) {
$regPath = “HKLM:\Software\Microsoft\Windows\CurrentVersion\RunOnce”
Remove-Folder “C:\Source\CW2014” -ErrorAction SilentlyContinue
Start-Sleep -Seconds 2
New-Item -ItemType Directory “C:\Source\CW2014” -Force
Copy-Item * C:\Source\CW2014 -Recurse -Force
Set-ItemProperty -Path $regPath -Name CW2014install -Value “C:\Source\CW2014\Deploy-Application.exe”
#Show-InstallationPrompt -Message “You will be prompted to install again in 24hrs.” -buttonrighttext “OK”
Write-Host “Exiting with code 3010”
exit 3010
}
}
}