Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 04-04-2018, 07:07 AM
yarthur01 yarthur01 is offline
Registered User
 
Join Date: Apr 2018
Posts: 2
VBScript close SecureCRT

I want to execute VBScript in Securecrt and close the Securecrt software after the script is executed. How to write the script?

the script as following

Code:
#$language = "VBScript"
#$interface = "1.0"

crt.Screen.Synchronous = True

' This automatically generated script may need to be
' edited in order to work correctly.

Sub Main
    Dim aclname
	Dim ipaddress
	aclname = crt.Arguments(0)
	ipaddress = crt.Arguments(1)
	crt.Screen.Send chr(13)
	crt.Screen.WaitForString "<H3C>"
	crt.Screen.Send "system-view" & chr(13)
	crt.Screen.WaitForString "[H3C]"
	crt.Screen.Send "interface Ethernet 1/0/1" & chr(13)
	crt.Screen.WaitForString "[H3C-Ethernet1/0/1]"
	crt.Screen.Send "undo packet-filter inbound ip-group " & aclname & chr(13)
	crt.Screen.WaitForString "[H3C-Ethernet1/0/1]"
	crt.Screen.Send "quit" & chr(13)
	crt.Screen.WaitForString "[H3C]"
	crt.Screen.Send "acl number " & aclname & chr(13)
	crt.Screen.WaitForString "[H3C-acl-adv-" & aclname & "]"
	crt.Screen.Send "rule deny ip source " & ipaddress & " 0" & chr(13)
	crt.Screen.WaitForString "[H3C-acl-adv-" & aclname & "]"
	crt.Screen.Send "rule deny ip destination " & ipaddress & " 0" & chr(13)
	crt.Screen.WaitForString "[H3C-acl-adv-" & aclname & "]"
	crt.Screen.Send "quit" & chr(13)
	crt.Screen.WaitForString "[H3C]"
	crt.Screen.Send "interface Ethernet 1/0/1" & chr(13)
	crt.Screen.WaitForString "[H3C-Ethernet1/0/1]"
	crt.Screen.Send "packet-filter inbound ip-group " & aclname & chr(13)
	crt.Screen.WaitForString "[H3C-Ethernet1/0/1]"
	crt.Screen.Send "quit" & chr(13)
	crt.Screen.WaitForString "[H3C]"
	crt.Screen.Send "quit" & chr(13)
	crt.Screen.WaitForString "<H3C>"
	crt.Session.Disconnect
End Sub

how to close the Securecrt after the script is executed?
Reply With Quote
  #2  
Old 04-04-2018, 08:52 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,116
Hi yarthur01,

I believe you are looking for the Quit() method available to the Application object:

Quit
Description
Causes SecureCRT to exit.
Remarks
A script that invokes Quit will be terminated immediately and cause SecureCRT to exit.
VBScript
Syntax
crt.Quit
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 04-06-2018, 09:44 PM
yarthur01 yarthur01 is offline
Registered User
 
Join Date: Apr 2018
Posts: 2
Thumbs up

Thank you for your advice!It works!
Reply With Quote
  #4  
Old 09-19-2018, 02:57 AM
jdtvds jdtvds is offline
Registered User
 
Join Date: Jun 2008
Posts: 1
Great !!! Perfect !

Always ended the SecureCRT session from Windows, but this is much better !
Reply With Quote
Reply

Tags
vbscript securecrt


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 09:39 AM.