我有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“
这件事的解决办法是什么?
发布于 2012-12-17 04:10:25
假设您希望从另一个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
https://stackoverflow.com/questions/13908131
复制相似问题