Dim procname$, rtn&
Private Sub Command1_Click()
procname = "explorer.exe"
strcomputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process Where Name = '" & procname & "'")
If colProcessList.Count = 0 Then
MsgBox procname & " 没有运行"
Else
For Each objProcess In colProcessList
rtn = MsgBox("您确定要终止 " & procname & " 吗?", vbYesNo, "强制关闭进程")
If rtn = 6 Then objProcess.Terminate
Next
End If
End Sub
|