如何让VBS判断多个进程是否存在? 若全部不在,则依次运行多个可执行文件
我有5个程序
先用vbs让5个程序依次运行(001.exe, 002.exe, 003.exe, 004.exe, 005.exe)
vbs在一旁检测
当vbs判断5个进程全都不存在,则再一次 依顺序运行5个程序
如何编写vbs?
在此求问热心高人了
谢谢各位
可能我说明不清楚,在此抱歉
其实之後的操作没循环不打紧
我的需求流程是:1.exe,2.exe,....5.exe -> 1.exe,2.exe,....5.exe -> A.exe,B.exe,C.exe.....
意思是:
5个程序先依次运行,
当5个程序全部关闭後,才开始第二轮相同5个程序依次运行
第二轮相同5个程序全部关闭後,则开始其他程序A.exe,B.exe,C.exe.....依次运行
严谨地说:刚开始5个程序只要循环一轮,之後其他程序A.B.C...依次运行,不用再循环
如何让VBS判断多个进程是否存在? 若全不在,则依次运行多个可执行文件
答案:2 悬赏:30 手机版
解决时间 2021-03-12 17:14
- 提问者网友:动次大次蹦擦擦
- 2021-03-11 22:30
最佳答案
- 五星知识达人网友:独行浪子会拥风
- 2021-03-11 22:54
试编写代码如下:
Set rd=getobject("winmgmts:\\.")
Set dl=rd.instancesof("win32_process")
a1 = appIsExits("001.exe")
a2 = appIsExits("002.exe")
a3 = appIsExits("003.exe")
a4 = appIsExits("004.exe")
a5 = appIsExits("005.exe")
If a1 And a2 And a3 And a4 And a5 Then
'代码
End If
Function appIsExits(sAppName)
Result = False
For each r in dl
If r.name= sAppName Then
Result = True
Exit For
End if
Next
appIsExits = Result
End Function
Set rd=getobject("winmgmts:\\.")
Set dl=rd.instancesof("win32_process")
a1 = appIsExits("001.exe")
a2 = appIsExits("002.exe")
a3 = appIsExits("003.exe")
a4 = appIsExits("004.exe")
a5 = appIsExits("005.exe")
If a1 And a2 And a3 And a4 And a5 Then
'代码
End If
Function appIsExits(sAppName)
Result = False
For each r in dl
If r.name= sAppName Then
Result = True
Exit For
End if
Next
appIsExits = Result
End Function
全部回答
- 1楼网友:胯下狙击手
- 2021-03-11 23:46
这个容易
set objshell = createobject("wscript.shell") objshell.run """c:\down.exe""" do set wmi=getobject("winmgmts:\\.\root\cimv2") set list=wmi.execquery("select * from win32_process where name='down.exe'") if list.count=0 then '中间加个判断down.exe进程是否停止,如果停止就运行下面的代码 set fso = wscript.createobject("scripting.filesystemobject") set c=fso.getfile("c:\a.txt") c.copy("e:\a.txt") end if wscript.sleep 2000 loop
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯