Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. processList = CrashPlanDesktop.exe|CrashPlanService.exe
  2.  
  3. ; If the script is not elevated, relaunch as administrator and kill current instance:
  4.  
  5. full_command_line := DllCall("GetCommandLine", "str")
  6.  
  7. if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
  8. {
  9.     try ; leads to having the script re-launching itself as administrator
  10.     {
  11.         if A_IsCompiled
  12.             Run *RunAs "%A_ScriptFullPath%" /restart
  13.         else
  14.             Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
  15.     }
  16.     ExitApp
  17. }
  18.  
  19. Loop, parse, processList, |
  20. {
  21. Process, wait, %A_LoopField%, 2
  22. PID = %ErrorLevel% 
  23.  
  24. if PID = 0
  25. continue
  26.  
  27. ;MsgBox Found pid "%PID%"
  28.  
  29. Process, priority, %PID%, Low
  30. Process, priority, , High
  31.  
  32. Process, Close, %PID%
  33. Run, %comspec% /c "taskkill /F /PID %PID% /T"
  34.  
  35. if ErrorLevel
  36.    MsgBox Unable to close process ID %PID%
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement