'杀掉包含指定参数的进程,这样可以区别杀掉指定某些进程 Private Function killProcessByPra(ByVal strProName$,ByVal strKeyPra$) As Boolean Dim objWMIService As Object Dim colProcessList As Object Dim objProcess As Object Dim objProType As Object Dim strResult As String Set objWMIService = GetObject("winmgmts:" & "{impersonationlevel=impersonate}!//./root/cimv2") Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process Where Name='" & strProName & "'") If colProcessList.Count <> 0 Then For Each objProcess In colProcessList For Each objProType In objProcess.Properties_ If objProType.Name = "CommandLine" Then If InStr(objProType.Value,strKeyPra) > 0 Then '如果包含指定关键字参数的进程就杀掉 objProcess.Terminate killProcessByPra = True End If End If Next Next End If End Function '检查是否包含指定关键字参数的进程,有的话就返回true Private Function isExistProcessByPra(ByVal strProName$,strKeyPra) > 0 Then '如果包含指定关键字参数的进程就返回true isExistProcessByPra = True Exit Function End If End If Next Next End If End Function