Solved

VBS Script Modification Pt3

Posted on 2012-03-11
7
351 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
Comment Utility
what's the error?
0
 

Author Comment

by:cpatte7372
Comment Utility
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
Comment Utility
try move this line:
crt.Session.Log True

above this line:
For nIndex = 1 to crt.GetTabCount
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:cpatte7372
Comment Utility
Sedgwick,

That worked.

Brilliant.....
0
 

Author Closing Comment

by:cpatte7372
Comment Utility
Excellent
0
 

Author Comment

by:cpatte7372
Comment Utility
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
Comment Utility
Whats the error on the 2nd time? What line?
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now