我有4个.vbs文件,比如A.VbS,B.VBS,C.VBS,D.VBS。我想按以下顺序打电话给他们:
(1)A.VBS
(2)B.VBS
(3)C.VBS
(4)D.VBS
当第一个完成时,第二个应该自动启动,依此类推。
你能帮我做这些任务吗?
修改
Option Explicit
Dim oShell : Set oShell = WScript.CreateObject ("WScript.Shell")
Dim FSO : set FSO = CreateObject("Scripting.FileSystemObject")
Dim Path
REM oShell.run "ParentChildLinkFinal.vbs", 1, True
REM oShell.run "Parent_Child_Merge_final.vbs", 1, True
REM oShell.run "Baddata.vbs", 1, True
REM oShell.run "CycleTime.vbs", 1, True
msgBox(oShell.CurrentDirectory)
MsgBox(FSO.GetFile(Wscript.ScriptFullName).ParentFolder )
Path=FSO.GetFile(Wscript.ScriptFullName).ParentFolder
oShell.run Path\ParentChildLinkFinal.vbs, 1, True
oShell.run Path\Parent_Child_Merge_final.vbs, 1, True
oShell.run Path\Baddata.vbs, 1, True
oShell.run Path\CycleTime.vbs, 1, True
我收到以下错误:
变量未定义:“arentChildLinkFinal.vbs”
对此有什么解决方法?
答案 0 :(得分:2)
假设您要从另一个VBS文件启动,如果工作目录与其他脚本相同,则可以使用以下内容,或者包含完整路径:
Dim oShell : Set oShell = WScript.CreateObject ("WScript.Shell")
oShell.run "A.VBS", 1, True
oShell.run "B.VBS", 1, True
oShell.run "C.VBS", 1, True
oShell.run "D.VBS", 1, True
作为替代方法,您还可以展开代码以将当前目录设置为包含脚本的文件夹:
Dim oShell : Set oShell = WScript.CreateObject ("WScript.Shell")
Dim FSO : Set FSO = CreateObject("Scripting.FileSystemObject")
oShell.CurrentDirectory = FSO.GetFile(Wscript.ScriptFullName).ParentFolder
oShell.run "A.VBS", 1, True
oShell.run "B.VBS", 1, True
oShell.run "C.VBS", 1, True
oShell.run "D.VBS", 1, True
有关参数和其他信息的含义,请参见此处: