KillProc plug-in: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (added category)
Line 27: Line 27:
     StrCpy $0 "foo.exe"
     StrCpy $0 "foo.exe"
     DetailPrint "Searching for processes called '$0'"
     DetailPrint "Searching for processes called '$0'"
     KillProc::FindProcesses
     KillProc::FindProcess
     StrCmp $1 "-1" wooops
     StrCmp $1 "-1" wooops
     DetailPrint "-> Found $0 processes"
     DetailPrint "-> Found $0 processes"
Line 49: Line 49:
     DetailPrint "Everything went okay :-D"
     DetailPrint "Everything went okay :-D"
   SectionEnd
   SectionEnd


=== Download ===
=== Download ===

Revision as of 18:41, 2 February 2008

KillProc Plugin for NSIS (2006-12-16)

This plugin is intended for searching and killing processes. Usefull if you want to kill all running instances of a certain application.


Functions

  • KillProc::FindProcesses - Enumerate all running instances of the specified process
  • KillProc::KillProcesses - Kills all running instances of the specified process


Parameters

  • $0: Specifies the name of the process to be killed (e.g. "foo.exe")


Return Values

  • $0: The number of processes found/killed
  • $1: The number of processes that could not be killed (-1 indicates serious problems)


Example

 Section
   StrCpy $0 "foo.exe"
   DetailPrint "Searching for processes called '$0'"
   KillProc::FindProcess
   StrCmp $1 "-1" wooops
   DetailPrint "-> Found $0 processes"
 
   StrCmp $0 "0" completed
   Sleep 1500
 
   StrCpy $0 "foo.exe"
   DetailPrint "Killing all processes called '$0'"
   KillProc::KillProcesses
   StrCmp $1 "-1" wooops
   DetailPrint "-> Killed $0 processes, faild to kill $1 processes"
 
   Goto completed
 
   wooops:
   DetailPrint "-> Error: Something went wrong :-("
   Abort

   completed:
   DetailPrint "Everything went okay :-D"
 SectionEnd

Download


Credits