Solved

VBS Script Modification Pt3

Posted on 2012-03-11
7
360 Views
Last Modified: 2012-03-11
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
Comment
Question by:cpatte7372
  • 4
  • 3
7 Comments
 
LVL 42

Expert Comment

by:sedgwick
ID: 37706731
what's the error?
0
 

Author Comment

by:cpatte7372
ID: 37706781
Hi Sedgwick,

Its run time error, please see attached for full description....
scripterror.jpg
0
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 37706798
try move this line:
crt.Session.Log True

above this line:
For nIndex = 1 to crt.GetTabCount
0
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 

Author Comment

by:cpatte7372
ID: 37706840
Sedgwick,

That worked.

Brilliant.....
0
 

Author Closing Comment

by:cpatte7372
ID: 37706841
Excellent
0
 

Author Comment

by:cpatte7372
ID: 37707628
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
 
LVL 42

Expert Comment

by:sedgwick
ID: 37707663
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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question