Archive: count process


count process
is it somehow possible to determine how many instances of explorer.exe are running?


maybe some additional explanation. i was asking for this, as i'd like a messagebox to pop up, if the user has any explorer windows open. if not, my installer will kill the remaining explorer instance and relaunch it.

if somebody has a better (more comfortable) idea, feel free to let me know!


unless the user has turned on "launch explorer in separate process" there will only be one instance of explorer.exe

You could use FindWindow and look for CabinetWClass


i have a need for this, to count how many (just example) "notepad.exe" processes are running

the 2-3 plugins to find running processes don't provide a way to get the PID so i can count them

anyone know how to use the system thing or something to give me the PIDs so i can count the processes?

thankyou :igor:


if you have a window handle you can use GetWindowThreadProcessId with the system plugin


There is a routine in the wiki ( http://nsis.sourceforge.net/FindProcess ) that could be easily modified to give you the count of processes which match a name you provide.

You would need to change a couple of lines to increment a counter and continue looking for the name (right now the code sets the return value to 1 and exits the loop).
Change lines 62-66 from

Pop $0          ; discard old result
Push 1 ; set return True

# exit the loop
${Break}
to
Pop $0           ; get current count
IntOp $0 $0 + 1 ; increment count
Push $0 ; save new count


Don

Psapi api is not present in Win9x apps.... :(
I'm making an plugin to detect the numbers of process by an executable, of course compatible for both systems: Win32 and NT :)


Tell me if this works for you...


w0w
that is pretty awesome, thanks Joel

and thanks demiller9, that would have worked for me too