I needed new functionality in my PowerShell install script (previously mentioned here). I needed the ability to make sure a process is not running, and if it is running, I could prompt the user to close it.
The new function takes the process name value from the config xml file (as I mentioned in previos post) and if it is running, displays a message box until the program is no longer running.
Function WaitForProcessToStop ($Step){
$ProcessName= ($Step.ProcessName.Value).split(".")[0]
if ($ProcessName -ne "") {
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
While (get-process $ProcessName -ea SilentlyContinue | select -Property Responding)
{
[System.Windows.Forms.MessageBox]::Show(
"Please close $ProcessName",
"Please close $ProcessName",
[System.Windows.Forms.MessageBoxButtons]::OK,
[System.Windows.Forms.MessageBoxIcon]::Information,
[System.Windows.Forms.MessageBoxDefaultButton]::Button1,
[System.Windows.Forms.MessageBoxOptions]::ServiceNotification
)
}
}
}
Comments are closed.