Tuesday, January 18, 2011

Passing Arguments To VB Script

Passing Arguments To VB Script

Recently I had a requirement where in I had to execute .vbs file by passing arguments from the command prompt  , instead of using input box. I am actually trying to initiate this vbs file from JAVA.

VB Script has the provision to pass the command line arguments. At the command prompt you can type following text c:\email.vbs arg1 arg2 arg3.... 


To access the above passed arguments, we need to use WScript.Arguments object, all the values are stored sequentially in an array format with index starting from zero.
Set objArgs = WScript.Arguments
Arg1 = objArgs(0)
Arg2 = objArgs(1)
Arg3 = objArgs(2)
---

No comments:

Post a Comment