This is how I'm passing arguments between files these days.
1.vbs:
Dim MyVar
'1) Assigning some value to MyVar.
MyVar = "foo"
'2) Passing MyVar to 2.vbs.
CreateObject("WScript.Shell").Run _
Chr(34) & "C:" & "\2.vbs" & _
Chr(34) & " " & Chr(34) & MyVar & Chr(34), _
1, True
'4) End point.
MsgBox MyVar
2.vbs:
If _
WScript.Arguments.Count > 0 _
Then
Call MySub( _
WScript.Arguments(0))
End If
Sub MySub(MyVar)
'3) Doing some work with MyVar.
MyVar = "bar"
End Sub
So, if all code was in 1 single file, and
if I had to use Call MySub instead of CreateObject("WScript.Shell").Run
— i'd successfully changed MyVar from "foo" to "bar",
and got the latter on MsgBox.
Yet, sometimes I really want to work with MyVar in another file,
and be able to get it back (to the already running first file) with changes.
I just don't know how to do that properly.
CreateObject("WScript.Shell").Runthis big file with specific arguments from smaller one-line files, "fixed" for any situation.ExecutGlobalto make a kind ofincludelike this example.