# $language = "VBScript" # $interface = "1.0" ' SetTraceLevel.vbs ' (for SecureCRT versions 6.5 and later) ' ' Description: ' This example script that shows how to set a more/less verbosity level for ' SecureCRT's "Trace Options" functionality. Often when troubleshooting a ' connectivity issue between client and server, it's helpful to know more ' about what's going on lower down in the protocol. If VanDyke Software ' technical support asks you to set Trace Level to a value greater than one, ' consider this script as an alternative to manually editing the .ini file. ' ' Usage: ' 1) Create a new button on the SecureCRT button bar (View / Button Bar), ' set the Function to "Run Script", and specify the path to this script ' file. Name the button something like "Debug" or "Set Trace", or ' whatever you feel fits best (you can always rename it later on if you ' think of a better fit). ' ' 2) Connect to the session you wish to modify. If this script is run in an ' instance of SecureCRT that has not yet connected to any remote machines ' it will be the "Default" session that gets modified. ' ' 3) Press the button you've created. ' - If the Trace Level is currently set to non-zero, the default value ' will be zero. ' - If the Trace Level is currently set to zero, the default value be ' be 5. ' ' 4) Specify a value between 0(none/off) and 9; then press OK. ' ' 5) Disconnect and reconnect to see the new verbosity level for trace ' options take effect (SecureCRT looks at the the Trace Level setting ' before a connection attempt is made). Sub Main() nCurrentTraceLevel = CInt(crt.Session.Config.GetOption("Trace Level")) If nCurrentTraceLevel > 0 Then nDefaultTraceLevelChange = 0 Else nDefaultTraceLevelChange = 5 End If Do nDefaultTraceLevelChange = crt.Dialog.Prompt(_ "Trace Options level for """ & crt.Session.Path & _ """ session is currently set to: " & nCurrentTraceLevel & "." & _ vbcrlf & vbcrlf & _ "Specify new Trace Options level below.", _ "Set Trace Options Level: " & crt.Session.Path, _ nDefaultTraceLevelChange) ' Check for user pressing "Cancel" button: If nDefaultTraceLevelChange = "" Then Exit Sub ' Check validity of data submitted by using a regular expression: Set re = New RegExp re.Pattern = "^[0-9]{1,2}$" re.Global = True re.Multiline = True ' If a valid trace level was specified, stop looping If re.Test(nDefaultTraceLevelChange) Then Exit Do crt.Dialog.Prompt _ """Trace Level"" setting must be specified as an integer" & _ vbcrlf & _ "between 0 and 9." Loop crt.Session.Config.SetOption "Trace Level", nDefaultTraceLevelChange ' Read the Trace Level back in so we can see if it was successfully set: nCurrentTraceLevel = CInt(crt.Session.Config.GetOption("Trace Level")) crt.Dialog.MessageBox _ "Trace Options level is now set to " & nCurrentTraceLevel & " for " & _ "session """ & crt.Session.Path & """" & vbcrlf & _ vbcrlf & _ "You must disconnect and reconnect for the changes to take effect." End Sub