# $language = "VBScript" # $interface = "1.0" ' TAPIReplacementDialer-UseSerial.vbs ' ' Last Modified: ' 14 Oct, 2018 ' - Initial revision ' ' Example script shows how to dial out to a number using the ' Serial protocol to talk directly to your modem, sometimes ' a viable workaround to problems that may otherwise may ' occur when Windows TAPI does the dialing. ' ' Argument to the script is the phone number sequence that ' should be dialed. For example: ' 9,1-555-555-1212 ' ' Alternatively, if there are no args to the script, this ' script will look in the "Description" field of the session ' options and if there's anything there that starts with ' '#:', this script will extract everything to the right of ' the #: as the number sequence to dial. For example: ' #:9,1-555-555-1212 ' If the above were located in the Description field, then ' the number dialed would be 9,1-555-555-1212 g_strScriptTitle = "SecureCRT - Serial COM Modem Dialer Script" Set g_fso = CreateObject("Scripting.FileSystemObject") Set g_shell = CreateObject("WScript.Shell") ' proc main Sub Main() strNumberToDial = "" ' Attempt to determine which number we're going to be dialing. ' First, check script args If crt.Arguments.Count > 0 Then strNumberToDial = crt.Arguments(0) Else vDescription = crt.Session.Config.GetOption("Description") ' First one wins For Each strLine In vDescription If Left(strLine, 2) = "#:" Then strNumberToDial = Mid(strLine, 3) End If Next End If If strNumberToDial = "" Then crt.Dialog.MessageBox _ "This script expects to find the phone number to dial " & _ "either 1) passed as an argument to the script, or 2) as a " & _ "line in the Description field in session options that" & _ "begins with the '#:' sequence. For example:" & vbcrlf & _ vbcrlf & _ vbtab & "Device Description:" & vbcrlf & _ vbtab & "#:9,1,555-555-1212" & vbcrlf & _ vbcrlf & _ "Please modify your session configuration to add a phone " & _ "number as an argument to the script or as part of the " & _ "'Description' field as described above.", _ g_strScriptTitle Exit Sub End If ' Second, check session Options 'Description' field crt.Screen.Synchronous = True ' Turn on Local Echo in SecureCRT so that we can see ' on the screen what is being sent to the modem (modem ' won't echo input by default) crt.Session.Config.SetOption "Local Echo", True crt.Screen.Send "AT" & vbcr If Not crt.Screen.WaitForString("OK", 3) Then crt.Dialog.MessageBox _ "Unable to communicate w/modem on " & _ crt.Session.Config.GetOption("Com Port"), _ g_strScriptTitle crt.Session.Disconnect Exit Sub End If ' Send a generic modem init string: You may need ' to modify this to meet your specific needs. crt.Screen.Send "AT&A3&B1&D0&K0&M4&N3&U3&R1" & vbcr If Not crt.Screen.WaitForString("OK", 3) Then crt.Dialog.MessageBox _ "Init sequence failed.", _ g_strScriptTitle crt.Session.Disconnect Exit Sub End If crt.Screen.Send "atdt" & strNumberToDial & vbcr nTimeout = 30 cResponses = CreateObject("Scripting.Dictionary") cResponses.Add "1", "CONNECT" cResponses.Add "2", "BUSY" cResponses.Add "3", "NO DIAL TONE" cResponses.Add "4", "NO CARRIER" ' Wait for any indication from the remote that there's an answer nResult = crt.Screen.WaitForStrings(cResponses.Keys(), nTimeout) If nResult <> 1 Then crt.Dialog.MessageBox _ "FAILURE: Did not successfully connect within " & _ nTimeout & " seconds when dialing " & _ strNumberToDial & vbcrlf & vbcrlf & _ "Failure Reason: " & cResponses(nResult) Exit Sub End If End Sub