WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Process ID

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Get process id from process name

 Keywords:  

Question:

I want to kill an Process from Task Manager automatic. Without using the askitemlist. How do I get a specific process name, and process id from the tListProc using ItemLocate and ItemExtract.

Answer:

The format of the process list, requires you search the list using strIndexNC instead of using the ItemExtract and ItemLocate functions....

Here is a UDF that should help...


#DefineFunction GetProcessID_UDF(proclist, procname)
	ptr=StrIndexNC(proclist,procname,0,@fwdscan)
	if ptr==0
	    Message(procname,"Not found")
	    exit
	endif
	
	ptr=StrIndex(proclist,"|",ptr,@fwdscan)
	ptr2=StrIndex(proclist,@tab,ptr,@fwdscan)
	pid=Strsub(proclist,ptr+1,ptr2-ptr-1)+0
	Return pid
#EndFunction
;Addextender("wproc34i.dll")
Addextender("wwprc44i.dll")

Processlist=tListProc()
processname="notepad"
procid = GetProcessID_UDF(processlist, processname)
Message(processname,procid)

Article ID:   W15077
File Created: 2017:07:28:12:58:38
Last Updated: 2013:04:01:08:07:45