Win 7 下 杀进程

Call KillProcess("Skype.exe,xmptipwnd.1.0.0.79.exe,KKV.exe,1905Server.exe,xmp.exe,QvodWebService.exe")
 
Function KillProcess(strProcessToKill)
 
 processArr = split(strProcessToKill,",")
 
 Const strComputer = "."
 Dim objWMIService, colProcessList
 Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
 
 'processArr
 dim cond
 if ubound(processArr) = 0 then
 
 Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name ='" & strProcessToKill & "'")
 else
 for j = 0 to ubound(processArr)
  if j = 0 then
   cond = "Name = '" & processArr(j) & "' "
  else
   cond = cond & " or Name = '" & processArr(j) & "' "
  end if
  
  Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE " & cond )
 next
end if
 
 For Each objProcess in colProcessList
 objProcess.Terminate()
 Next
 
End Function



你可能感兴趣的:(win7,vbs,杀进程)