回复 5# yapda - Option Explicit
-
- Main
- Sub Main()
- Dim sExeName, sExePath, sDoCmd, sSql
- sExeName = "cmd.exe" 'qq.exe
- sExePath = "C:\windows\system32\cmd.exe" 'd:\qq.exe
- sDoCmd = "taskkill /f /im 1.exe /im 2.exe /im 3.exe" '刪除3個進程
-
- sSql = "Select * From Win32_Process Where Name='{P1}' And CommandLine Like '%{P2}%'"
- sExePath = Replace(sExePath,"\","\\")
- sSql = Replace(sSql,"{P1}",sExeName)
- sSql = Replace(sSql,"{P2}",sExePath)
-
- Dim wim, wso, fso, n
- Set wim = GetObject("winmgmts:")
- Set wso = CreateObject("WScript.Shell")
- Set fso = CreateObject("Scripting.filesystemobject")
-
- Do While n < 2
- If Not fso.FileExists(sExePath) Then Exit Do
- If wim.ExecQuery(sSql).Count = 0 Then
- n = n + 1
- If n = 2 Then
- wso.Run sDoCmd, 1, True
- End If
- wso.Run """" & sExePath & """", 1, False
- Else
- Exit Do
- End If
- WScript.Sleep 50 * 1000
- Loop
-
- If wim.ExecQuery(sSql).Count = 0 Then
- wso.Run "shutdown /r /t 10 /f ", 0, False '重启
- End If
- End Sub
复制代码
|