Talk:KillProc plug-in: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
No edit summary
Line 1: Line 1:
There's a simple alternative to the KillProc plugin on windows. The following example would terminate all processes with the name "ExeToKill.exe"...
There's a simple alternative to the KillProc plugin on windows. The following example would terminate all processes with the name "ExeToKill.exe"...


=== Example ===
Your sample plugin syntax would only make sense if the description said :
ExecWait "taskkill /f /im ExeToKill.exe"
 
:That application is only present on Windows XP and above. --[[User:Kichik|kichik]] 19:43, 10 March 2009 (UTC)
$0 the number of processes found/killed
$1 the number of processes not found/killed #### Request that discription of $1 be revised.
 
The snippet only says 'killed' for $1, so the coding in the section does not make sense that it would only error out on $1 if a process cannot be "killed" (see ##########comment):
 
Section
  StrCpy $0 "foo.exe"
  DetailPrint "Searching for processes called '$0'"
  KillProc::FindProcesses
  StrCmp $1 "-1" wooops ############### Why is $1 being used here if $1 is only for issues with kill?
  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, failed to kill $1 processes"
  Goto completed
  wooops:
  DetailPrint "-> Error: Something went wrong :-("
  Abort
 
  completed:
  DetailPrint "Everything went okay :-D"
SectionEnd

Revision as of 23:54, 9 November 2009

There's a simple alternative to the KillProc plugin on windows. The following example would terminate all processes with the name "ExeToKill.exe"...

Your sample plugin syntax would only make sense if the description said :

$0 the number of processes found/killed $1 the number of processes not found/killed #### Request that discription of $1 be revised.

The snippet only says 'killed' for $1, so the coding in the section does not make sense that it would only error out on $1 if a process cannot be "killed" (see ##########comment):

Section

  StrCpy $0 "foo.exe"
  DetailPrint "Searching for processes called '$0'"
  KillProc::FindProcesses
  StrCmp $1 "-1" wooops ############### Why is $1 being used here if $1 is only for issues with kill?
  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, failed to kill $1 processes"

  Goto completed

  wooops:
  DetailPrint "-> Error: Something went wrong :-("
  Abort
  completed:
  DetailPrint "Everything went okay :-D"
SectionEnd