View Single Post
  #1  
Old 09-18-2018, 12:24 PM
cynarl cynarl is offline
Registered User
 
Join Date: Sep 2018
Posts: 2
run function in all active sessions

I created a script to send multiple commands in all active sessions, but these commands are in another function, so when I run this script all the commands are send to one session.

Code:
Sub Main
	crt.Session.ConnectInTab("/S session1")
	Function1
	crt.Session.ConnectInTab("/S session2")
	Function1
    For nIndex = 1 to crt.GetTabCount
        Set objCurrentTab = crt.GetTab(nIndex)
        objCurrentTab.Activate
        if objCurrentTab.Session.Connected = True Then
        	Function1
        end if
    Next
End Sub

Sub Function1
	crt.Screen.Send "command 1" & vbcr
        crt.Screen.Send "command 2" & vbcr
End Sub

Last edited by jdev; 09-18-2018 at 12:44 PM. Reason: wrap code in [code] blocks to preserve indentation
Reply With Quote