帮我跑了一系列的.bat脚本VBS脚本 - 运行一系列.batch工作
它们位于像这样的:
号码:\联名\ export.bat 号码:\通用\ export.bat 号码:\三品牌\ export.bat
由于提前, 最好的问候, 乔
帮我跑了一系列的.bat脚本VBS脚本 - 运行一系列.batch工作
它们位于像这样的:
号码:\联名\ export.bat 号码:\通用\ export.bat 号码:\三品牌\ export.bat
由于提前, 最好的问候, 乔
发现,工作的方式,应该尝试此首先。 我有点不好意思,这是这其实很容易:
CD,P:\联名\
CALL Export.bat
CD,P:\通用\
CALL出口。蝙蝠
CD,P:\ TriBrand \
CALL Export.bat
CD,P:\ UBA \
CALL Export.bat
会简单的shell命令吗?您可以从命令提示符调用此:
for /R %F in (*.bat) do "%F"
或.bat文件如下:
for /R %%F in (*.bat) do call "%%F"
按照最初的要求,这里是一个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
以及我真的很想做的是从一个.vbs脚本的末尾执行批处理脚本我一直有问题试图从cmd提示符和.bat脚本运行这些没有找到正确的路径由于某种原因,它似乎使用的是从执行它的位置开始的路径,而不是从实际的.bat脚本的位置开始。希望.vbs脚本能够提供帮助,但它的样子它可能会通过任何方式来指定路径,使用文件放置的路径? – jmituzas 2010-10-13 13:19:44