我正在编写一个运行外部程序的脚本,一段时间后终止它,相关代码部分如下所示:
Set objshell=createObject("Wscript.Shell")
objShell.run ""app.exe""
objShell.run ""app.exe""
WScript.Sleep(5000)
strWmiq = "select * from Win32_Process where name='app.exe'"
Set objQResult = objWmi.Execquery(strWmiq)
For Each objProcess In objQResult
intRet = objProcess.Terminate(1)
Next
我想要做的是在不同的 sleep 时间后关闭 app.exe
的每个实例,有什么想法如何做到这一点吗?
最佳答案
使用 WScript.Shell 的 .Exec 方法为 app.exe 的每个 session /运行/实例获取 WshScriptExec 对象,并在您闲暇时(并承担风险)终止它们。请参阅Terminate Method (WshScriptExec)
关于process - vbscript-终止流程实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13901549/