0

I write a VBScript script in which I call another process. I want to pass to that child process all the command line arguments my script got.

How can I do that efficiently and elegantly?

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
SomethingSomething
  • 11,491
  • 17
  • 68
  • 126

1 Answers1

1

Arguments passed into a vbscript are held in the Arguments collection. You can get to these with the following code:

argument1 = WScript.Arguments(0)
argument2 = WScript.Arguments(1)
...

And so on. Once you have them it's simple enough to pass them onto the process you are calling by using them in the command line that executes the child process

Dim myShell : Set myShell = CreateObject("Wscript.Shell")
myShell.Run "cscript.exe <path to child vbs> " & Chr(34) & argument1 & Chr(34) & " " & chr(34) & argument2 & Chr(34)
Dave
  • 4,328
  • 2
  • 24
  • 33