Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


How To: Parameter Passing to an external VBS script

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,63341
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> How To: Parameter Passing to an external VBS script
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 How To: Parameter Passing to an external VBS script - 8/12/2008 12:37:52 AM   
  stephen.wolfe

 

Posts: 77
Score: 0
Joined: 8/9/2005
From: Tampa, FL
Status: online
Just how do you do that?  Look at he little code snippet below:


      

I want to pass three parameters to that script, do I define the parameters as Public in the invoking script and how do I mod the above line to get the parameters across?

Thanks!!!

_____________________________

Steve
 
 
Post #: 1
 
 RE: How To: Parameter Passing to an external VBS script - 8/12/2008 1:00:52 AM   
  nilpo1

 

Posts: 21
Score: 0
Joined: 1/22/2006
Status: offline
Values can be passed into another script as command line arguments.  You just need to add them to your existing command line.  Be sure that there are spaces between them.  Any values containing spaces will need to be enclosed in quotation marks.

      

You can read arguments into a script by accessing WScript's Arguments collection.

      

_____________________________

Scripting problems? Windows questions? Ask the Windows Guru!

(in reply to stephen.wolfe)
 
 
Post #: 2
 
 RE: How To: Parameter Passing to an external VBS script - 8/12/2008 7:39:38 AM   
  Fredledingue


Posts: 383
Score: 0
Joined: 5/9/2005
From:
Status: offline
To my experience you can pass only one argument to a vbscript launched that way.
If the example above doesn't work, just split the argument:

Arg = Split(WScript.Arguments.Item(0), " ")
TimeToWait = Arg(0)
val1 = Arg(1)
val2 = Arg(2)

_____________________________

Fred

(in reply to nilpo1)
 
 
Post #: 3
 
 RE: How To: Parameter Passing to an external VBS script - 8/12/2008 11:18:28 PM   
  mbouchard


Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: online
You could also use Named and unnamed arguments.  The benifit of named arguments is that if one is not passed it would not mess up your target script.

i.e.

testscript.vbs arg1 arg2 arg3

Using regular arguments your target script will always be looking for the 3 arguments and if one is not included could mess up your target script.  Now, if you will always pass 3 arguments then that is not an issue.  If there is a chance you may not pass 3 than you can look at Named arguments.

here is an example I found a good while ago on the use of named and unnamed arguments

      

here is my command
Source Script

      

Target Script

      

_____________________________

Mike

For useful Scripting links see the Read Me First stickey!

Always remember Search is your friend.

(in reply to Fredledingue)
 
 
Post #: 4
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> How To: Parameter Passing to an external VBS script Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts