Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VBS Script Modification Pt3

Posted on 2012-03-11
7
Medium Priority
?
366 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:Meir Rivkin
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:
Meir Rivkin earned 2000 total points
ID: 37706798
try move this line:
crt.Session.Log True

above this line:
For nIndex = 1 to crt.GetTabCount
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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:Meir Rivkin
ID: 37707663
Whats the error on the 2nd time? What line?
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses
Course of the Month10 days, 14 hours left to enroll

885 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