Archive: How to get process info by name


How to get process info by name
I need to know the process id knowing only its name.
I need its pid so I can kill the right instance because of I have many processes with the same name. My idea was to run the process, takes its id and store it. Then when I need, I run another time the same process and I kill the last instance of it by pid.
If you can tell me how to make with System32 call I think it's better if it isn't so difficult. I saw ProcFunc.nsh but I can't download it. My download is blocked. I saw also GetProcessInfo.nsh but I think it work only for the current process and not for others.

Thanks in advance

p.s.
Also using GetProcessInfo, obtaining my pid, passing it in someway to the main setup. I need to kill it by pid. And I still don't know how to do it with nsis.T.T


I'm sorry for the useless thread. I found procfunc.nsh in google docs -.-


procfunc dont run on 64bit IMO, use WMIC (windows built in) instead.

type for more --> wmic process get /?

nsExec::Exec "wmic /OUTPUT:C:\proclist.txt PROCESS get Caption,Commandline"
note: "name" and "caption" and "description" seems equal
output is in UTF-8 - converter:
;convert text
FileOpen $0 "C:\proclist.txt" r
FileOpen $1 "C:\proclist.new" w
FileReadByte $0 $2
FileReadByte $0 $2
init02:
ClearErrors
FileReadByte $0 $2
IfErrors init03
IntCmp $2 0x00 init02 0 0
FileWritebyte $1 $2
Goto init02
init03:
FileClose $1
FileClose $0

Ok thank you very much for the help. =)

I used
nsExec::ExecToStack "wmic process where name='myprocname.exe' get processid /VALUE"

I obtain "processid=<PROC_ID>" so I have only to split it.
Anyway thank you again for your suggestion =)


so I have only to split it.
same here - i read line and cut the details for me.
StrStr may help -> http://nsis.sourceforge.net/StrStr