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:
File A.vbs is located in C:\temp
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
加载中,请稍侯......
精彩评论