首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >自动调用.VBS文件

自动调用.VBS文件
EN

Stack Overflow用户
提问于 2012-12-17 04:04:46
回答 1查看 1.3K关注 0票数 1

我有4个.vbs文件,例如,A.VbS、B.VBS、C.VBS、D.VBS。我想按以下顺序调用它们:

代码语言:javascript
复制
        (1)A.VBS
        (2)B.VBS
        (3)C.VBS
        (4)D.VBS

当第一个操作完成时,第二个应该自动启动,依此类推。

你能帮我做这样的工作吗?

编辑:

代码语言:javascript
复制
    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“

这件事的解决办法是什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-12-17 04:10:25

假设您希望从另一个VBS文件启动,如果工作目录与其他脚本相同,或者以其他方式包含完整路径,则可以使用以下内容:

代码语言:javascript
复制
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

作为另一种选择,您还可以展开代码将当前目录设置为包含脚本的文件夹:

代码语言:javascript
复制
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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13908131

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档