Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 367
  • Last Modified:

VBS Script Modification Pt3

Hello Experts,

The following script fails when it gets to the line 'crt.session.log True'. Its being used with an application called SecureCRT and its run on a number of tabs. Basically, the script will work fine on the first tab, but when it gets to another tab I get the error message CRT Scripting Runtime error, and then it says Logging already enabled.

I think its because script doesn't recognise that it should start afresh on a new tab.

I wonder if you could assist?

# $language = "VBScript"
# $interface = "1.0"
' SendToAll.vbs

Sub Main()
   
    if Not crt.Session.Connected then
        szSession = crt.Dialog.Prompt("Enter session:", "", "", False)
        if szSession = "" then exit sub
   
        crt.Session.ConnectInTab("/S " & szSession)
        crt.Session.ConnectInTab("/S " & szSession)
        crt.Session.ConnectInTab("/S " & szSession)
    end if
   
    arrCommands = Array("end", "term len 0")

    ' Send commands to all tabs
    ' Connect to each tab in order from left to right, issue all commands, and
    ' then disconnect...
    For nIndex = 1 to crt.GetTabCount
        Set objCurrentTab = crt.GetTab(nIndex)
        objCurrentTab.Activate
      
            
        If objCurrentTab.Session.Connected = True Then
            crt.Session.Log True
            For Each strCommand In arrCommands
                crt.Sleep 500
                objCurrentTab.Screen.Send strCommand & vbcr
            
                crt.Sleep 1000
            Next
        End If
    Next
End Sub
                                           

Cheers

Carlton
0
cpatte7372
Asked:
cpatte7372
  • 4
  • 3
1 Solution
 
Meir RivkinFull stack Software EngineerCommented:
what's the error?
0
 
cpatte7372Author Commented:
Hi Sedgwick,

Its run time error, please see attached for full description....
scripterror.jpg
0
 
Meir RivkinFull stack Software EngineerCommented:
try move this line:
crt.Session.Log True

above this line:
For nIndex = 1 to crt.GetTabCount
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
cpatte7372Author Commented:
Sedgwick,

That worked.

Brilliant.....
0
 
cpatte7372Author Commented:
Excellent
0
 
cpatte7372Author Commented:
sedgwick,

I tried the script again and unfortunately I was wrong. It only works once but won't work multiple times.

Can you help or should I ask again?

Cheers
0
 
Meir RivkinFull stack Software EngineerCommented:
Whats the error on the 2nd time? What line?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now