NsProcess plugin: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
Instructor (talk | contribs) (→Links) |
m (→Links) |
||
(15 intermediate revisions by 9 users not shown) | |||
Line 3: | Line 3: | ||
== Links == | == Links == | ||
Download v1.1:<br> | Download v1.5: | ||
<attach>nsProcess.zip</attach> | *[[Image:Zip.gif]] <span class="plainlinks">[http://nsis.sourceforge.net/mediawiki/images/archive/1/18/20140806212030!NsProcess.zip nsProcess.zip]</span> (25 KB) | ||
Download v1.6 (NSIS UNICODE support, by [[user:brainsucker|brainsucker]], rename nsProcessW.dll):<br/> | |||
*<attach>nsProcess.zip</attach> | |||
*Mirror: [http://forums.winamp.com/attachment.php?attachmentid=48936&d=1309248568 nsProcess_1_6.7z] | |||
Discussion:<br> | Discussion:<br> | ||
Line 11: | Line 15: | ||
== Description == | == Description == | ||
'''Features:''' | '''Features:''' | ||
*Find | *Find a process by name | ||
*Kill all processes with specified name (not only one) | *Kill all processes with specified name (not only one) | ||
*Close all processes with specified name (first tries to close all process windows, waits for 3 seconds for process to exit, terminates if still alive, use _CloseProcess function) | |||
*The process name is case-insensitive | *The process name is case-insensitive | ||
*Win95/98/ME/NT/2000/XP support | *Win95/98/ME/NT/2000/XP/Win7 support | ||
*Small plugin size (4 | *Finds processes of other user(s) when running 'as Administrator' or when having switched to another user | ||
*Small plugin size (4 Kb) | |||
*NSIS UNICODE support (just rename nsProcessW.dll into nsProcess.dll) | |||
== Example Usage == | |||
<highlight-nsis> | |||
!include "LogicLib.nsh" | |||
Section "" | |||
StrCpy $1 "YOURAPP.exe" | |||
nsProcess::_FindProcess "$1" | |||
Pop $R0 | |||
${If} $R0 = 0 | |||
nsProcess::_KillProcess "$1" | |||
Pop $R0 | |||
Sleep 500 | |||
${EndIf} | |||
SectionEnd | |||
</highlight-nsis> | |||
Commonly _FindProcess returns: | |||
* 0 if found | |||
* 603 if no process matched | |||
// Return codes are as follows: | |||
// 0 = Success | |||
// 601 = No permission to terminate process | |||
// 602 = Not all processes terminated successfully | |||
// 603 = Process was not currently running | |||
// 604 = Unable to identify system type | |||
// 605 = Unsupported OS | |||
// 606 = Unable to load NTDLL.DLL | |||
// 607 = Unable to get procedure address from NTDLL.DLL | |||
// 608 = NtQuerySystemInformation failed | |||
// 609 = Unable to load KERNEL32.DLL | |||
// 610 = Unable to get procedure address from KERNEL32.DLL | |||
// 611 = CreateToolhelp32Snapshot failed | |||
== Thanks == | == Thanks == | ||
Ravi Kochhar (source function FIND_PROC_BY_NAME based upon his [http://www.physiology.wisc.edu/ravi/Software/ code]) | Ravi Kochhar (source function FIND_PROC_BY_NAME based upon his [http://www.physiology.wisc.edu/ravi/Software/ code])<br> | ||
<br>iceman_k ([[ | iceman_k ([[Find Process By Name]]) and DITMan ([[KillProcDLL Manual]]) for direct me | ||
[[Category:Plugins]] | [[Category:Plugins]] |
Latest revision as of 23:34, 20 November 2021
Author: Instructor (talk, contrib) |
Links
Download v1.5:
- nsProcess.zip (25 KB)
Download v1.6 (NSIS UNICODE support, by brainsucker, rename nsProcessW.dll):
- nsProcess.zip (14 KB)
- Mirror: nsProcess_1_6.7z
Discussion:
Forum thread
Description
Features:
- Find a process by name
- Kill all processes with specified name (not only one)
- Close all processes with specified name (first tries to close all process windows, waits for 3 seconds for process to exit, terminates if still alive, use _CloseProcess function)
- The process name is case-insensitive
- Win95/98/ME/NT/2000/XP/Win7 support
- Finds processes of other user(s) when running 'as Administrator' or when having switched to another user
- Small plugin size (4 Kb)
- NSIS UNICODE support (just rename nsProcessW.dll into nsProcess.dll)
Example Usage
!include "LogicLib.nsh" Section "" StrCpy $1 "YOURAPP.exe" nsProcess::_FindProcess "$1" Pop $R0 ${If} $R0 = 0 nsProcess::_KillProcess "$1" Pop $R0 Sleep 500 ${EndIf} SectionEnd
Commonly _FindProcess returns:
- 0 if found
- 603 if no process matched
// Return codes are as follows: // 0 = Success // 601 = No permission to terminate process // 602 = Not all processes terminated successfully // 603 = Process was not currently running // 604 = Unable to identify system type // 605 = Unsupported OS // 606 = Unable to load NTDLL.DLL // 607 = Unable to get procedure address from NTDLL.DLL // 608 = NtQuerySystemInformation failed // 609 = Unable to load KERNEL32.DLL // 610 = Unable to get procedure address from KERNEL32.DLL // 611 = CreateToolhelp32Snapshot failed
Thanks
Ravi Kochhar (source function FIND_PROC_BY_NAME based upon his code)
iceman_k (Find Process By Name) and DITMan (KillProcDLL Manual) for direct me