Thursday, May 1, 2014

Task Kill for 32bit & 64bit applications



On Error Resume Next

strComputer = "."

set objWMIService = GetObject ("winmgmts:")
 foundProc = False
 procName = "Receiver.exe"

 for each Process in objWMIService.InstancesOf ("Win32_Process")
     If StrComp(Process.Name,procName,vbTextCompare) = 0 then
         foundProc = True
         procID = Process.ProcessId
     End If
 Next
 If foundProc = True Then
          Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process where ProcessId =" & procID)
     For Each objProcess in colProcessList
         objProcess.Terminate()
     Next
   
 End If

No comments:

Post a Comment