Check if Multiple processes are running

Hi,
I’m using the below Script to detect whether winword is Running, so that the End user can close the program prior to a software install. is there a way I can check for other running programs in the same script? such as excel,outlook,MSaccess,OneNote,POWERPNT.

Many thanks

$DLGProcesses = @(Get-WmiObject -Query “select * FROM Win32_process WHERE name=‘Winword.exe’” -ErrorAction SilentlyContinue)
if ($DLGProcesses.Count -eq 0) {
Try {
Write-Output “Office is not started, we can run the installation in session 0”
Start-Process Deploy-Application.exe -Wait -ArgumentList ‘-DeployMode “NonInteractive”’
}
Catch {
$ErrorMessage = $.Exception.Message
$ErrorMessage
}
}
else {
Try {
Write-Output “Office is started, we need to run the installation in session 1, ServiceUI.exe”
.\ServiceUI.exe -process:explorer.exe Deploy-Application.exe
}
Catch {
$ErrorMessage = $
.Exception.Message
$ErrorMessage
}

}
##Write-Ouput “Exit Code of Installation is: $LASTEXITCODE”
exit $LASTEXITCODE

1 Like

Hi Steve,

yes you can use the internal function from psadt: Show-InstallationWelcome to close multiple processes e.g. Office Suite etc.

Check AppDeployToolkitHelp.ps1 for details.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.