$odis = Get-Process OffboardDiagLauncher -ErrorAction SilentlyContinue
if ($odis) {
# Close process safely
$odis.CloseMainWindow()
# Wait 5 seconds
Sleep 5
if (!$odis.HasExited) {
# Force stop process
$odis | Stop-Process -Force
}
}
Remove-Variable odis
Powershell: Stop Process safely when the process is running or not
by
Tags:
Leave a Reply