1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
' 获取操作系统管理服务对象 Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") ' 创建 WshShell 对象 Set WshShell = CreateObject("WScript.Shell") ' 定义函数:检查进程是否正在运行 Function IsProcessRunning(processName) ' 查询指定进程名的进程集合 Set colProcesses = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = '" & processName & "'") ' 返回进程数量 IsProcessRunning = (colProcesses.Count > 0) End Function ' 检查并处理 taskbar.exe 进程 If Not IsProcessRunning("taskbar.exe") Then ' 启动 taskbar.exe WshShell.Run """D:\Program Files (x86)\AriaNg Native\taskbar.exe""", 1, False ' 等待 taskbar.exe 启动完成 Do ' 检查 taskbar.exe 进程是否已经启动完成 If IsProcessRunning("taskbar.exe") Then Exit Do End If WScript.Sleep 100 ' 休眠100毫秒 Loop End If ' 检查 AriaNg Native.exe 进程 If Not IsProcessRunning("AriaNg Native.exe") Then ' 启动 AriaNg Native.exe WshShell.Run """D:\Program Files (x86)\AriaNg Native\AriaNg Native.exe""", 1, False ' 等待 AriaNg Native.exe 启动完成 Do ' 检查 AriaNg Native.exe 进程是否已经启动完成 If IsProcessRunning("AriaNg Native.exe") Then Exit Do End If WScript.Sleep 100 ' 休眠100毫秒 Loop End If ' 开始监测 AriaNg Native.exe 的运行状态 Do WScript.Sleep 5000 ' 休眠5秒 If Not IsProcessRunning("AriaNg Native.exe") Then ' AriaNg Native.exe 关闭时,结束 taskbar.exe 和 aria2c.exe 进程 Set colProcesses = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'taskbar.exe' OR Name = 'aria2c.exe'") For Each process In colProcesses process.Terminate Next Exit Do End If Loop |
发表回复