I have a vbscript that I would like to call from another script and at the same time pass some data of various types from the "calling" script - is that possible?

What I would like to achieve is exactly what a function does, only that instead of referring to the function's name, I would like to be able to refer to a script file and pass my variables to that

I come from an Macintosh/AppleScript background and there one could use:
"run script [path to script] with parameters [the parameters you like] "
Is that possible in vbscript? Or if not, Is there any other easy of achieving the same effect.

All suggestions are much appreciated

/ Richard

Re: Newbie, How to pass data from one vbscript to another? by Torgeir

Torgeir
Sun Jun 20 16:45:56 CDT 2004

Richard Ronnback wrote:
> I have a vbscript that I would like to call from another script and at the same time pass some data of various types from the "calling" script - is that possible?
>
> What I would like to achieve is exactly what a function does, only that instead of referring to the function's name, I would like to be able to refer to a script file and pass my variables to that
>
> I come from an Macintosh/AppleScript background and there one could use:
> "run script [path to script] with parameters [the parameters you like] "
> Is that possible in vbscript?
Hi

Yes, that is possible with VBScript.

Here is an example on how to run another script and pass it a parameter
on the command line:

' first script, calling another script with parameters on the command line
Set oShell = CreateObject("WScript.Shell")
oShell.Run "wscript.exe C:\Test.vbs param1 param2", 1, True


In the C:\Test.vbs file, you access the command line parameters with
the WScript.Arguments object, here is an example:


Set oArgs = WScript.Arguments
' first parameter
WScript.Echo oArgs(0)
' second parameter
WScript.Echo oArgs(1)


If you want to enumerate the parameters:

Set oArgs = WScript.Arguments
For i = 0 to oArgs.Count - 1
WScript.Echo oArgs(i)
Next


WSH 5.6 documentation (local help file) can be downloaded from here if you
haven't got it already:
http://msdn.microsoft.com/downloads/list/webdev.asp



--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/community/scriptcenter/default.mspx

Re: Newbie, How to pass data from one vbscript to another? by RichardRonnback

RichardRonnback
Mon Jun 21 00:40:01 CDT 2004

Thanks!

It seems to be exaclyt what I am looking for! I should be able to tweak the samples you gave to do what I need.

Thanks again!

/ Richard


"Torgeir Bakken (MVP)" wrote:

> Richard Ronnback wrote:
> > I have a vbscript that I would like to call from another script and at the same time pass some data of various types from the "calling" script - is that possible?
> >
> > What I would like to achieve is exactly what a function does, only that instead of referring to the function's name, I would like to be able to refer to a script file and pass my variables to that
> >
> > I come from an Macintosh/AppleScript background and there one could use:
> > "run script [path to script] with parameters [the parameters you like] "
> > Is that possible in vbscript?
> Hi
>
> Yes, that is possible with VBScript.
>
> Here is an example on how to run another script and pass it a parameter
> on the command line:
>
> ' first script, calling another script with parameters on the command line
> Set oShell = CreateObject("WScript.Shell")
> oShell.Run "wscript.exe C:\Test.vbs param1 param2", 1, True
>
>
> In the C:\Test.vbs file, you access the command line parameters with
> the WScript.Arguments object, here is an example:
>
>
> Set oArgs = WScript.Arguments
> ' first parameter
> WScript.Echo oArgs(0)
> ' second parameter
> WScript.Echo oArgs(1)
>
>
> If you want to enumerate the parameters:
>
> Set oArgs = WScript.Arguments
> For i = 0 to oArgs.Count - 1
> WScript.Echo oArgs(i)
> Next
>
>
> WSH 5.6 documentation (local help file) can be downloaded from here if you
> haven't got it already:
> http://msdn.microsoft.com/downloads/list/webdev.asp
>
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/community/scriptcenter/default.mspx
>