Advertisement
tolikpunkoff

Macro KillProc

Apr 18th, 2023
1,940
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. !macro PrintProcError ErrCode
  2.     ${Switch} ${ErrCode}
  3.         ${Case} '0'
  4.             DetailPrint "Success"
  5.         ${Break}
  6.         ${Case} '601'
  7.             DetailPrint "No permission to terminate process"
  8.         ${Break}
  9.         ${Case} '602'
  10.             DetailPrint "Not all processes terminated successfully"
  11.         ${Break}
  12.         ${Case} '603'
  13.             DetailPrint "Process was not currently running"
  14.         ${Break}
  15.         ${Case} '604'
  16.             DetailPrint "Unable to identify system type"
  17.         ${Break}
  18.         ${Case} '605'
  19.             DetailPrint "Unsupported OS"
  20.         ${Break}
  21.         ${Case} '606'
  22.             DetailPrint "Unable to load NTDLL.DLL"
  23.         ${Break}
  24.         ${Case} '607'
  25.             DetailPrint "Unable to get procedure address from NTDLL.DLL"
  26.         ${Break}
  27.         ${Case} '608'
  28.             DetailPrint "NtQuerySystemInformation failed"
  29.         ${Break}
  30.         ${Case} '609'
  31.             DetailPrint "Unable to load KERNEL32.DLL"
  32.         ${Break}
  33.         ${Case} '610'
  34.             DetailPrint "Unable to get procedure address from KERNEL32.DLL"
  35.         ${Break}
  36.         ${Case} '611'
  37.             DetailPrint "CreateToolhelp32Snapshot failed"
  38.         ${Break}
  39.     ${EndSwitch}
  40. !macroend
  41.  
  42. !macro KillProc Proc
  43.     DetailPrint "Find process ${Proc}..."
  44.     nsProcess::_FindProcess "${Proc}"
  45.     Pop $R0
  46.     !insertmacro PrintProcError $R0
  47.     ${If} $R0 = 0
  48.         DetailPrint "Process ${Proc} found. Kill it..."
  49.         nsProcess::_KillProcess "${Proc}"
  50.         !insertmacro PrintProcError $R0
  51.         Sleep 500
  52.     ${EndIf}
  53. !macroend
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement