开发者

Call another vbscript

I have a vbscript file A that will call another vbscript file B. File B requires arguments and it is located in the same folder with file A.

The code works like this:

  1. File A.vbs is located in C:\temp

  2. In File A, call C:\temp\B.vbs

Wherever folder I put these vbs files, as long as they are on the same folder, file A should call file B without cha开发者_JAVA百科nging the code. How can I do this in VBScript?


I'm not sure what the question is but it sounds like you're wondering how you know what path to use. If so, I think that it should just work with a relative path like .\B.vbs.

Otherwise if the question is how do you execute one script from another, look at Shell.Run.

So all put together, something like WshShell.Run ".\B.vbs arg1 arg2" should work I think.

Edit: If the relative path doesn't work, just use WScript.ScriptFullName to get the path of the currently executing script as:

WshShell.Run Replace(WScript.ScriptFullName, WScript.ScriptName, "") & "B.vbs arg1 arg2"


Try this:

Dim aShell
Set aShell = CreateObject ("WScript.Shell")
aShell.Run "B.vbs"
Set aShell = Nothing
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜