- NSIS Discussion
- about KillProcDLL::KillProc
Archive: about KillProcDLL::KillProc
51819
17th June 2007 08:30 UTC
about KillProcDLL::KillProc
I have tried to use killproc to kill all processes with a name. Inevitably, it kills only one of them with that name. How can I make it kill them all?
Examples:my PC is running 4 programs. I want to use "KillProcDLL::KillProc" to kill all them,when i install/Uninstall.
Afrow UK
17th June 2007 09:16 UTC
Perhaps it would be better to use this plugin:
http://nsis.sourceforge.net/wiki/Processes_plug-in
Use the FindProcess function in a loop with KillProcess.
Stu
51819
17th June 2007 09:58 UTC
Originally posted by Afrow UK
Perhaps it would be better to use this plugin:
http://nsis.sourceforge.net/wiki/Processes_plug-in
Use the FindProcess function in a loop with KillProcess.
Stu
sorry sir.
I don't konw how to write Use the FindProcess function in a loop with KillProcess.
Afrow UK
17th June 2007 10:22 UTC
loop:
Processes::FindProcess "process_name" ;without ".exe"
StrCmp $R0 1 0 done
Processes::KillProcess "process_name" ;without ".exe"
StrCmp $R0 1 loop
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "process_name could not be closed.$\r$\nTry again?" IDOK loop
Abort
done:
Stu
51819
17th June 2007 11:46 UTC
Originally posted by Afrow UK
loop:
Processes::FindProcess "process_name" ;without ".exe"
StrCmp $R0 1 0 done
Processes::KillProcess "process_name" ;without ".exe"
StrCmp $R0 1 loop
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "process_name could not be closed.$\r$\nTry again?" IDOK loop
Abort
done:
Stu
Thank you sir
Takhir
17th June 2007 13:51 UTC
BTW KillProcDLL also returns some value :) To kill them all just use it in loop with "...check out $R0 to get the return value". Plug-in returns 0 if "Process was successfully terminated".
Afrow UK
17th June 2007 14:37 UTC
Ah yes :)
loop:
KillProcDLL::KillProc "process_name.exe"
StrCmp $R0 603 done
StrCmp $R0 0 loop
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "process_name could not be closed.$\r$\nTry again?" IDOK loop
Abort
done:
Stu
vc6
12th July 2007 03:26 UTC
Hmmm... I was looking for a solution to a similar problem (killing a process before uninstalling (deleting) its .exe) and I luckily found this thread.
However, I am somewhat confused by the code you posted here:
First, the readme.txt that accompanies that plugin demonstrates getting the return code by first popping $R0:
Processes
::KillProcess "process_name"
Pop $R0
StrCmp $R0"1" dead_meat why_wont_you_die
dead_meat:
...
why_wont_you_die:
...
However, I tested the code with using the statement Pop $R0 and it seems to work, too. Why? Which is more correct?
Thanks,
Victor
Afrow UK
12th July 2007 12:16 UTC
My code is wrong. You need to Pop $R0 with Processes, but KillProcDll simply puts its output into $R0 (without using pushstring internally).
Stu
zanz
24th July 2008 19:38 UTC
I have an issue where I need to launch an *.exe but need to kill the running process first.
The issue is the timing. Sometimes it takes a few sections to kill the running process and the *.exe gets launched from within the script (while the process has not been killed).
Further, I need to launch the *.exe silently. Using a loop to kill the process is not feasible for this situation (I’m concerned about a condition failing and my installation getting stuck in a loop – all silently). Is there an alternative? Something similar to ExecWait (where the script would wait to execute the next line until the process has been killed).
Thanks!
LoRd_MuldeR
24th July 2008 19:45 UTC
You could try the "KillProc" plugin instead of "KillProcDLL" here:
http://nsis.sourceforge.net/KillProc_plug-in
It should be able to kill 'em all http://www.airborneranger.com/forums...k/headbang.gif
zanz
25th July 2008 02:07 UTC
This seems like a good plugin, something I was trying to write.
I will give it a try in a day or so. Thanks for the pointer!
LoRd_MuldeR
25th July 2008 02:11 UTC
Originally posted by zanz
This seems like a good plugin, something I was trying to write.
I will give it a try in a day or so. Thanks for the pointer!
Be aware: This was tested on WinXP only, never tested it on Vista...