我想要.vbs脚本,打开多个大文件.vbs [我想逐个打开.vbs]不能让我,在PC中滞后。
0001.vbs,0002.vbs,0003.vbs,0004.vbs 可以是不同的名称,如: Anna.vbs,Diana.vbs,Antony.vbs,Andy.vbs
示例:
run C:\0001.vbs
MsgBox "0001.vbs IS END"
Next Open run C:\0002.vbs
MsgBox YES NO
MsgBox "0002.vbs IS END"
Next Open run C:\0003.vbs
MsgBox YES NO
MsgBox "0003.vbs IS END"
Next Open run C:\0004.vbs
MsgBox YES NO
MsgBox "0004.vbs IS END"
谢谢你的帮助。
答案 0 :(得分:2)
Set Shell = CreateObject("WScript.Shell")
For i = 1 To 4
strFile = Right("0000" & i, 4) & ".vbs"
If MsgBox("Would you like to run " & strFile & "?", vbYesNo Or vbQuestion) = vbYes Then
Shell.Run "c:\" & strFile, 1, True
MsgBox strFile & " IS END"
End If
Next
请确保将True
作为最后一个参数传递给Shell.Run
,以便此脚本在报告结束之前等待其他脚本完成。
编辑:要回答有关使用名称的评论,您可以循环浏览即时创建的数组。
For Each strName In Array("Anna", "Diana", "Antony", "Andy")
Next
答案 1 :(得分:1)
要不让你等到每个子进程/ .vbs开始下一步,不要使用./ 3的wait / wait / true参数方法:
a.vbs
Option Explicit
Dim oWSH : Set oWSH = CreateObject("WScript.Shell")
Dim v
For v = 0 To 1
oWSH.Run "cscript.exe " & v & ".vbs", 0, False
Next
MsgBox WScript.ScriptName & " done. " & Now()
0.vbs,1.vbs
Option Explicit
Randomize
WScript.Sleep Rnd() * 1000
MsgBox WScript.ScriptName & " done. " & Now()
证据:
如您所见,a.vbs首先完成,0.vbs和1.vbs以随机/非呼叫顺序终止。