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