方法一:
Set WMI=GetObject("winmgmts:\\.\root\cimv2")
Set ProgList=WMI.ExecQuery("Select * From Win32_Process")
For Each Prog In ProgList
If LCase(Prog.Name)="cmd.exe" Then
Prog.Terminate
Exit For
End If
Next
方法二:
Set WshShell=CreateObject("Wscript.Shell")
Set WMI=GetObject("winmgmts:\\.\root\cimv2")
Set ProgList=WMI.ExecQuery("Select * From Win32_Process")
For Each Prog In ProgList
If LCase(Prog.Name)="cmd.exe" Then
wshshell.Run "cmd /c ntsd -c q -p "+Prog.ProcessID,0
Exit For
End If
Next
P.S. ntsd 可以结束任何进程(除了系统关键进程)