1

4つの.vbsファイルがあります。たとえば、A.VbS、B.VBS、C.VBS、D.VBSです。以下の順番で呼びたいです。

        (1)A.VBS
        (2)B.VBS
        (3)C.VBS
        (4)D.VBS

最初の処理が完了すると、2番目の処理が自動的に開始されます。

そのような仕事をするのを手伝ってくれませんか。

編集:

    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"

これに対する修正は何ですか?

4

1 に答える 1

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

パラメータの意味およびその他の情報については、ここを参照してください。

http://technet.microsoft.com/en-us/library/ee156605.aspx

于 2012-12-17T04:10:25.473 に答える