Check
Check if exe is running and optionally terminate itI have no problems running that script.
>I have a little more info that may help:
>
>I issued this from a VFP app I am running:
>
>&& In case the COM's did not release properly, kill them.
> lcComputer = '.'
> loWMIService = Getobject('winmgmts:' ;
> + '{impersonationLevel=impersonate}!\\' + lcComputer + '\root\cimv2')
> lcprocname="ITFCOMLEFT.EXE"
> colProcessList = loWMIService.ExecQuery([Select * from Win32_Process where Name="]+lcProcName+["])
> For Each loProcess In colProcessList
> IF UPPER(loProcess.name) = lcprocname
> loProcess.terminate()
> endif
> NEXT
> lcprocname="ITFCOMRGHT.EXE"
> colProcessList = loWMIService.ExecQuery([Select * from Win32_Process where Name="]+lcProcName+["])
> For Each loProcess In colProcessList
> IF UPPER(loProcess.name) = lcprocname
> loProcess.terminate()
> endif
> NEXT
>
> WAIT CLEAR
>
> loWMIService=.NULL.
> RELEASE loWMIService
> RELEASE colProcessList=.NULL.
> RELEASE colProcessList
> RELEASE loProcess
>
>VFP generates an error on the "colProcessList = loWMIService.ExecQuery([Select * from Win32_Process where Name="]+lcProcName+["])
>" line of code.
>
>colprocessList is an object (can't see what is in it), but it appears the loWMIService may not "understand" the ExecQuery command or something. loProcess does NOT become an object.
>
>Perhaps the '\root\cimv2' is not good or something? I have no idea what '\root\cimv2' means.
>
>John
If it's not broken, fix it until it is.
My Blog