guyrleech

Display dialogue on process exit

Aug 23rd, 2024
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PowerShell 0.61 KB | Software | 0 0
  1. ## display dialogue when a process exits
  2. ## must be run with PowerShell 7.x as Windows PowerShell doesn't have the required Wait-Process arguments
  3. ## could use -id instead of -name and -any to wait for a specific process instance that you know the pid of
  4.  
  5. date;$null = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.VisualBasic");$p = $null;$p=Wait-Process -name OfficeClickToRun -any -passthru|? ExitCode -ne $null;[Microsoft.VisualBasic.Interaction]::MsgBox("Started at $($p.StartTime), finished at $($p.ExitTime), exit code $($p.ExitCode)" , 'OKOnly,SystemModal,Exclamation' , "Process $($p.Name) Exited" )
Add Comment
Please, Sign In to add comment