Welcome to the VanDyke Software Forums

Join the discussion today!

Go Back   VanDyke Software Forums > Scripting


Thread Tools Rate Thread Display Modes
Old 08-03-2020, 11:25 AM
vstaral vstaral is offline
Registered User
Join Date: Aug 2020
Posts: 4
Using vbscript to clone session to new window...

Good Day: I recently started creating vbscripts to use with SecureCRT, and I must say I'm glad that capability exists!

I currently launch a script which opens a SecureCRT window, allows me to log into a session, and then creates three session clones. What I'd like to do is have that same script bring up a second SecureCRT window, allow me to log into a session, and then make clones of that. From what little bit I've tried today, I can create the second SecureCRT window from the script and log in, but the script goes back and executes commands in the first window instead of the second window.

Does such capability exist? If not, is there a different way I could achieve this goal? My main focus is to have all the work be done by a single script.

Reply With Quote
Old 08-03-2020, 04:23 PM
dayde dayde is offline
Registered User
Join Date: Jun 2019
Posts: 5
I'm not 100% sure I follow, but I do know the capability exists to clone a session (however many times you need to) and treat the clones differently as far as running commands, etc. I have not used vbscript in a decade or so, but I know the capability exists.

Mind sharing the code you are using?
Reply With Quote
Old 08-04-2020, 07:11 AM
bgagnon bgagnon is offline
VanDyke Technical Support
Join Date: Oct 2008
Posts: 4,636
Hi vstaral,

Sorry, presently there is not a way to accomplish your objective.

I have added this thread to a feature request in our product enhancement database to add API(s) for controlling tabs across multiple main application windows. Should a future release of SecureCRT include this feature, notification will be posted here.

If you prefer direct email notification, send an email to support@vandyke.com and include Feature Request - Forum Thread #14247 in the subject line or use this form from the support page of our website.

VanDyke Software
Technical Support
(505) 332-5730
Reply With Quote
Old 08-09-2020, 02:13 PM
gregg gregg is offline
Registered User
Join Date: Oct 2010
Posts: 75

I can think of 2 possible work-arounds.

1. Create a second script that clones the current session 3 times when executed and in Session->Logon Actions->Logon Script set it to this new script. Theoretically, at connect time, the script will launch and do the cloning.
You could get fancy by counting the number of open tabs and if it's 1, do the cloning; if not 1, don't clone.

2. In your current script, launch a new instance of securecrt which passes a /SCRIPT to start a cloning script (same idea as 1).

#$language = "VBScript"
#$interface = "1.0"

Dim g_shell
Set g_shell = CreateObject("WScript.Shell")

scrt = "C:\path\to\VanDyke Software\SecureCRT\SecureCRT.exe"
script = "C:\path\to\scripts\clonescript.vbs"

command = chr(34) & scrt & chr(34) & " /SCRIPT " & chr(34) & script & chr(34)

waitOnReturn = 0
windowStyle = 0

g_shell.Run command, windowStyle, waitOnReturn
Using WScript.Shell and Run is in some of the included SecureCRT example scripts, but not specifically like this.

I would probably lean towards option 1 if that worked.
Reply With Quote
Old 08-13-2020, 09:42 AM
vstaral vstaral is offline
Registered User
Join Date: Aug 2020
Posts: 4
Hello Gregg, I like your ideas. Thanks! I plan to try them in the near future.
Reply With Quote
Old 08-19-2020, 07:35 AM
vstaral vstaral is offline
Registered User
Join Date: Aug 2020
Posts: 4
I was looking at the workarounds and discovered I need to provide more detail regarding the functionality I'm seeking.

I have a script that automates the ability to log into a router and connect to multiple async ports. The credentials, router address, and async port information are entered on a form generated by an IE Application Object (see attached).

After the information is entered, the script will log into a terminal session, router, and the first async port. Next, it will create up to nine clones of that session and in each clone log into the router and an async port. That way the script can log me into ten async ports on one router.

What I would like the script to do is, if I want to log into more than ten async ports (since that's the maximum number of sessions I can comfortably view in one SecureCRT window), have the script bring up a session in a new SecureCRT window, log into the router and async port, and then make as many clones as necessary. The trick that's eluding me is how to allow the script to take control of the new SecureCRT window and pass the information to those new sessions.

It sounds like that functionality is not yet implemented in SecureCRT, but is there a workaround that could possibly accomplish these tasks?

Attached Images
File Type: jpg IE Application Object.jpg (25.2 KB, 1655 views)

Last edited by cboyack; 08-19-2020 at 07:42 AM. Reason: Made image viewable in-line. Please refer to https://forums.vandyke.com/showthread.php?t=14212 for instructions
Reply With Quote

clone session , vbscript

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -6. The time now is 01:19 PM.