Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Here is my code:
DebugTrace(@on,"Trace.txt") ;Addextender("wproc34I.dll") AddExtender("wwprc44i.dll") Locator = ObjectOpen("WbemScripting.SWbemLocator") Service = Locator.ConnectServer("","root/cimv2","","") Security = Service.Security_ Security.ImpersonationLevel = 3 colAdapters = Service.ExecQuery("Select ProcessID from Win32_Process Where Caption = 'java.exe'") hEnum = ObjectCollectionOpen(colAdapters) While 1 Obj = ObjectCollectionNext(hEnum) If Obj == 0 then Break ProcID = Obj.ProcessID EndWhile hProcess=tOpenProc(ProcID,3);!!!!! 202 Error Occurs Here result = tKillProc(hProcess) tcloseproc(hProcess) ObjectCollectionClose(hEnum)
I am logged in as the local administrator, running Windows XP. I am able to terminate the process using TaskManager and IntControl 56.
What could be the problem?
Note: WinClose does not work on java.exe
This problem may have be resolved in version 10013 of the Process extender. It seems as though, on NT, the calling process must be given seDebugName privilege in order to open a process with the PROCESS_TERMINATE access flag (3). The tOpenProc function didn't handle this until now.
Starting in version 10013 of the Process extender:
Rev 10013 Dec 12, 2003 Modified tOpenProc to set the SE_DEBUG_NAME privilege when using PROCESS_TERMINATE(3) on NT platforms.Reference: MicroSoft KB Article 131065
Alternatively you can use WinItemProcId and IntControl 56 to close a process based on the Process id.
; Using WinItemProcId and IntControl 56 ;Addextender("wproc34I.dll") AddExtender("wwprc44i.dll") idlist=tListProc() list=Askitemlist("Choose Java.exe from the list",idlist,@TAB,@SORTED,@SINGLE) ; parse off process ID and Name procid=itemextract(2,list,"|") ;Get a list of window ids associates with that process id winids = WinItemProcId(procid, 15, 0) ;Loop thru all windows and terminate them For xx = 1 to ItemCount(winids,@tab) id=ItemExtract(xx,winids,@tab) if WinExist(id) then IntControl(56,id,0,@TRUE,0) Next Exit
Article ID: W15865
File Created: 2013:04:01:09:13:56
Last Updated: 2013:04:01:09:13:56