How can I pass arguments to my script?

Note: The following capability requires at least CRT™ /SecureCRT® version 4.0.

You can now pass arguments to ActiveX scripts (running in CRT) by using the /ARG command-line option to pass arguments to CRT and then retrieving those arguments in your script using the "Arguments" object.

The example below is a common script that connects to multiple hosts and performs the same operation on each host, having been passed variable arguments for hostname, username, and port.

' Detect lack of proper arguments.
If crt.Arguments.Count < > 3 Then
MsgBox "This script requires hostname, username, and port arguments"
Exit Sub
End If

hostname = crt.Arguments(0)
username = crt.Arguments(1)
port = crt.Arguments(2)

The arguments are then made available to scripts by starting different instances of CRT and using the /ARG command-line option to pass the data. In the example below, two instances of CRT are started and different hostnames, usernames, and ports are made available to scripts being run by those instances of CRT:

CRT.exe /ARG router1 /ARG admin1 /ARG 5001
CRT.exe /ARG router2 /ARG admin2 /ARG 2400
Was this information helpful?
Yes No

Thank you!
Send your comments and questions to VanDyke Software Support,
or join the discussion in the VanDyke Software Forums.

Can't find the answer you're looking for?
Ask VanDyke Software Support directly
and we will get back to you as soon as possible.


VanDyke Software uses cookies to give you the best online experience. Before continuing to use this site, please confirm that you agree to our use of cookies. Please see our Cookie Usage for details.