帮我运行一系列.bat脚本
它们的位置如下:
号码:\联合品牌\ export.bat 电话号码:\通用\ export.bat 号码:\三品牌\ export.bat
提前致谢, 最好的祝福, 乔
答案 0 :(得分:0)
一个简单的shell命令会吗?您可以从命令提示符处调用它:
for /R %F in (*.bat) do "%F"
或.bat文件中的以下内容:
for /R %%F in (*.bat) do call "%%F"
答案 1 :(得分:0)
找到了一种有效的方法,首先应该尝试过。 我有点尴尬,实际上这很容易:
cd P:\ Co-Brand \
CALL Export.bat
cd P:\ Generic \
CALL Export.bat
cd P:\ TriBrand \
CALL Export.bat
cd P:\ UBA \
CALL Export.bat
答案 2 :(得分: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等待一个“.bat”完成,然后继续执行下一个操作,则设置blnWaitOnReturn = False,并删除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
...
如果您希望能够获取“Status”和“ProcessID”,并且在进程执行时访问可执行文件的标准流以实时读取/写入进程的stdout / stderr,那么使用“objShell” .Exec”。
有关“objShell.Exec”的更多信息,请访问:http://ss64.com/vb/exec.html