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 changing 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.ScriptFullNameto get the path of the currently executing script as: