Vbscript 自动调用.VBS文件

Vbscript 自动调用.VBS文件,vbscript,Vbscript,我有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

我有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”


此问题的解决方法是什么?

假设您希望从另一个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
有关参数和其他信息的含义,请参见此处:


谢谢彼得,谢谢你的帮助!:-)我能帮点忙吗?是的,这是正确的,尽管我似乎记得默认的开始路径可能会因Windows版本或启动方式而有所不同,因此如果遇到任何未找到的文件问题,请尝试使用完整路径。我经常在Windows任务事件中进行类似的思考,这样可以设置脚本位置的默认路径。好的!我现在正在启动我的脚本。但是如果在运行时我们可以将文件路径捕获到一个变量中,然后将其添加到.vbs文件中,这可能会更好。可能吗?您需要的是oShell.CurrentDirectory,请在此处查看您编辑的部分,您需要在名称周围加引号,例如“Path\ParentChildLinkFinal.vbs”。对不起,我看到path是一个变量。请用第二个示例检查我的更新答案,这样您就不需要包含路径,它可以是“ParentChildLinkFinal.vbs”。@PeterJ您今天为我提供的非常好的概念!!我刚刚给了你
+1
。我想我的帖子也得到了更多的
+1
来将这种研究引入
StackOverflow