[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
  1. Option Explicit
  2. Main
  3. Sub Main()
  4.     Dim sExeName, sExePath, sDoCmd, sSql
  5.     sExeName = "cmd.exe"    'qq.exe
  6.     sExePath = "C:\windows\system32\cmd.exe"    'd:\qq.exe
  7.     sDoCmd = "taskkill /f /im 1.exe /im 2.exe /im 3.exe"    '刪除3個進程
  8.     sSql = "Select * From Win32_Process Where Name='{P1}' And CommandLine Like '%{P2}%'"
  9.     sExePath = Replace(sExePath,"\","\\")
  10.     sSql = Replace(sSql,"{P1}",sExeName)
  11.     sSql = Replace(sSql,"{P2}",sExePath)
  12.     Dim wim, wso, fso, n
  13.     Set wim = GetObject("winmgmts:")
  14.     Set wso = CreateObject("WScript.Shell")
  15.     Set fso = CreateObject("Scripting.filesystemobject")
  16.     Do While n < 2
  17.         If Not fso.FileExists(sExePath) Then Exit Do
  18.         If wim.ExecQuery(sSql).Count = 0 Then
  19.             n = n + 1
  20.             If n = 2 Then
  21.                 wso.Run sDoCmd, 1, True
  22.             End If
  23.             wso.Run """" & sExePath & """", 1, False
  24.         End If
  25.         WScript.Sleep 50 * 1000
  26.     Loop
  27. End Sub
复制代码
1

评分人数

    • yapda: 就是厉害的技术 + 1
『千江有水千江月』千江有水,月映千江;万里无云,万里青天。    http://yu2n.qiniudn.com/

TOP

回复 3# yapda
  1. Option Explicit
  2. Main
  3. Sub Main()
  4.     Dim sExeName, sExePath, sDoCmd, sSql
  5.     sExeName = "cmd.exe"    'qq.exe
  6.     sExePath = "C:\windows\system32\cmd.exe"    'd:\qq.exe
  7.     sDoCmd = "taskkill /f /im 1.exe /im 2.exe /im 3.exe"    '刪除3個進程
  8.     sSql = "Select * From Win32_Process Where Name='{P1}' And CommandLine Like '%{P2}%'"
  9.     sExePath = Replace(sExePath,"\","\\")
  10.     sSql = Replace(sSql,"{P1}",sExeName)
  11.     sSql = Replace(sSql,"{P2}",sExePath)
  12.     Dim wim, wso, fso, n
  13.     Set wim = GetObject("winmgmts:")
  14.     Set wso = CreateObject("WScript.Shell")
  15.     Set fso = CreateObject("Scripting.filesystemobject")
  16.     Do While n < 2
  17.         If Not fso.FileExists(sExePath) Then Exit Do
  18.         If wim.ExecQuery(sSql).Count = 0 Then
  19.             n = n + 1
  20.             If n = 2 Then
  21.                 wso.Run sDoCmd, 1, True
  22.             End If
  23.             wso.Run """" & sExePath & """", 1, False
  24.         End If
  25.         WScript.Sleep 50 * 1000
  26.     Loop
  27.     If wim.ExecQuery(sSql).Count = 0 Then
  28.         wso.Run "shutdown /r /t 10 /f ", 0, False    '重启
  29.     End If
  30. End Sub
复制代码
1

评分人数

    • yapda: 完美 解决技术 + 1
『千江有水千江月』千江有水,月映千江;万里无云,万里青天。    http://yu2n.qiniudn.com/

TOP

回复 5# yapda
  1. Option Explicit
  2. Main
  3. Sub Main()
  4.     Dim sExeName, sExePath, sDoCmd, sSql
  5.     sExeName = "cmd.exe"    'qq.exe
  6.     sExePath = "C:\windows\system32\cmd.exe"    'd:\qq.exe
  7.     sDoCmd = "taskkill /f /im 1.exe /im 2.exe /im 3.exe"    '刪除3個進程
  8.     sSql = "Select * From Win32_Process Where Name='{P1}' And CommandLine Like '%{P2}%'"
  9.     sExePath = Replace(sExePath,"\","\\")
  10.     sSql = Replace(sSql,"{P1}",sExeName)
  11.     sSql = Replace(sSql,"{P2}",sExePath)
  12.     Dim wim, wso, fso, n
  13.     Set wim = GetObject("winmgmts:")
  14.     Set wso = CreateObject("WScript.Shell")
  15.     Set fso = CreateObject("Scripting.filesystemobject")
  16.     Do While n < 2
  17.         If Not fso.FileExists(sExePath) Then Exit Do
  18.         If wim.ExecQuery(sSql).Count = 0 Then
  19.             n = n + 1
  20.             If n = 2 Then
  21.                 wso.Run sDoCmd, 1, True
  22.             End If
  23.             wso.Run """" & sExePath & """", 1, False
  24.         Else
  25.             Exit Do
  26.         End If
  27.         WScript.Sleep 50 * 1000
  28.     Loop
  29.     If wim.ExecQuery(sSql).Count = 0 Then
  30.         wso.Run "shutdown /r /t 10 /f ", 0, False    '重启
  31.     End If
  32. End Sub
复制代码
1

评分人数

    • yapda: 万分感谢 大神的耐心技术 + 1
『千江有水千江月』千江有水,月映千江;万里无云,万里青天。    http://yu2n.qiniudn.com/

TOP

返回列表