2010-10-12 57 views
0

幫我跑了一系列的.bat腳本VBS腳本 - 運行一系列.batch工作

它們位於像這樣的:

號碼:\聯名\ export.bat 號碼:\通用\ export.bat 號碼:\三品牌\ export.bat

由於提前, 最好的問候, 喬

回答

0

發現,工作的方式,應該嘗試此首先。 我有點不好意思,這是這其實很容易:

CD,P:\聯名\

CALL Export.bat

CD,P:\通用\

CALL出口。蝙蝠

CD,P:\ TriBrand \

CALL Export.bat

CD,P:\ UBA \

CALL Export.bat

0

會簡單的shell命令嗎?您可以從命令提示符調用此:

for /R %F in (*.bat) do "%F" 

或.bat文件如下:

for /R %%F in (*.bat) do call "%%F" 
+0

以及我真的很想做的是從一個.vbs腳本的末尾執行批處理腳本我一直有問題試圖從cmd提示符和.bat腳本運行這些沒有找到正確的路徑由於某種原因,它似乎使用的是從執行它的位置開始的路徑,而不是從實際的.bat腳本的位置開始。希望.vbs腳本能夠提供幫助,但它的樣子它可能會通過任何方式來指定路徑,使用文件放置的路徑? – jmituzas 2010-10-13 13:19:44

0

按照最初的要求,這裏是一個VBScript的解決方案...

描述可能與「腳本工作的目錄的問題」。

嘗試......

Dim objShell 
    Dim blnWaitOnReturn 
    Dim strOriginalCD 
    Dim strCmd 
    Dim intWindowStyle 
    Dim intExitCode 

    Set objShell = WScript.CreateObject("Wscript.Shell") 
'' if necessary, save the original "Script-Working-Directory" 
    strOriginalCD = objShell.CurrentDirectory 

    intWindowStyle = 1 
    blnWaitOnReturn = True 

    objShell.CurrentDirectory = "p:\Co-Brand\" 
    strCmd = "%comspec% /K export.bat" 
    intExitCode = objShell.Run(strCmd, intWindowStyle, blnWaitOnReturn) 

    objShell.CurrentDirectory = "p:\Generic\" 
    strCmd = "%comspec% /K export.bat" 
    intExitCode = objShell.Run(strCmd, intWindowStyle, blnWaitOnReturn) 

    objShell.CurrentDirectory = "p:\Tri-Brand\" 
    strCmd = "%comspec% /K export.bat" 
    intExitCode = objShell.Run(strCmd, intWindowStyle, blnWaitOnReturn) 

'' if necessary, restore the original "Script-Working-Directory" 
    objShell.CurrentDirectory = strOriginalCD 

注:

'' If filename contains spaces make sure to add double-quotes around filename 
    strCmd = "%comspec% /K " & Chr(34) & "File name with spaces.bat" & Chr(34) 

'' To run the commands in a "Hidden" window, use: 
    intWindowStyle = 0 

'' To run the commands "Minimized", use: 
    intWindowStyle = 7 

的 「objShell.Run」 更多信息可以在這裏找到:http://ss64.com/vb/run.html

以上的例子會導致VBScript來等待每個被調用的「.bat」完成並返回「ExitCode」,然後繼續。

如果你不想VBScript來等待一個「蝙蝠」在進行下一步之前完成再設置blnWaitOnReturn =假,並刪除intExitCode,如:

... 
    blnWaitOnReturn = False 

    objShell.CurrentDirectory = "p:\Co-Brand\" 
    strCmd = "%comspec% /K export.bat" 
    objShell.Run strCmd, intWindowStyle, blnWaitOnReturn 

    objShell.CurrentDirectory = "p:\Generic\" 
    strCmd = "%comspec% /K export.bat" 
    objShell.Run strCmd, intWindowStyle, blnWaitOnReturn 

    objShell.CurrentDirectory = "p:\Tri-Brand\" 
    strCmd = "%comspec% /K export.bat" 
    objShell.Run strCmd, intWindowStyle, blnWaitOnReturn 
    ... 

如果你想的能力,獲取「狀態」和「流程ID」,並訪問可執行文件的標準流,以在流程執行時實時讀取/寫入流程的stdout/stderr,然後使用「objShell.Exec」。

更多關於「objShell。執行「可以在這裏找到:http://ss64.com/vb/exec.html