VanDyke Software Forums

VanDyke Software Forums (
-   Scripting (
-   -   Reference a saved session (

paul- 08-29-2018 03:31 PM

Reference a saved session

Is it possible to reference/connect to a session(s) that has been saved in the 'Sessions' folder/subfolders?

In my script, I'm wanting to take a users input for a folder and connect to the devices in the selected folder.


ekoranyi 08-29-2018 04:21 PM

Hi paul-,

It is possible to connect to a saved session using the Connect method. The Connect method takes a string parameter that specifies how a connection is to be made. The format of the string parameter matches the format of the command line arguments to SecureCRT.

The format for specifying a saved session is:

/S session_name
Starts SecureCRT and opens a connection A data path or circuit between two computers over a phone line, network cable, or other means. with session_name. If session_name includes any spaces, it must be enclosed with quotation marks, (e.g., "My Session").
This may look something like:

crt.session.Connect("/s folder/mysession")
Your use case of connecting to every session in a folder may be a bit more difficult. You would most likely need to recursively iterate over the folder and capture all the session names, then connect to each. Can you help me better understand your use case and why you would like your users to specify a folder and connect to each session by script? Would simply right clicking on a folder in the Session Manager and choosing Connect In Tabs be an option?

paul- 08-29-2018 04:37 PM

Thanks for the reply Eric. The use case is to run a script to connect to a list of devices and then execute commands on those selected devices. In this case, I would be selecting a folder of devices.

I'm specifically thinking to open the sessions from the folders, in order to skip doing authentication via the script and instead use the saved credentials in the saved sessions.

Although, I hadn't thought of opening the sessions first and then running a script against the open tabs. I might look into doing that instead.


ekoranyi 08-29-2018 04:59 PM


If it were me I would definitely approach it from the "other way". Connecting to all the required sessions first in SecureCRT then running your script on each. This seems not only less prone to errors but easier to script by a large margin.

After connecting to all the needed devices I see a couple of different options to run your script. You could write your script to iterate over all open tabs running the needed commands on each. Another, and again easier option, would be to use SecureCRT's Button Bar.

To enable the Button Bar choose View > Button bar. The Button Bar should appear at the bottom of the SecureCRT window. Right clicking on the Button Bar will allow you to create a new button. As the Function choose Run Script. After selecting your script and choosing a Label save your changes.

Now you can simply click the button to run the script in the currently active tab, or even better, hold Shift and click the button to run the script in all tabs.

Using the Button Bar would make the script much easier to write (no recursion or looping through the tabs) and make the process fairly efficient. Right click on a folder in the Session Manager and choose Connect in Tabs then hold Shift and click a button on the Button Bar.

All times are GMT -6. The time now is 08:14 AM.