Windows平台SecureCRT结合vbs脚本自动配置交换机文件

结合SecureCRT一起使用

Sub Main
     Const ForReading = 1, ForWriting = 2, ForAppending = 8
     Dim fso,file1,line,str1,params 
     Set fso = CreateObject("Scripting.FileSystemObject")
     Set file1 = fso.OpenTextFile("C:\HUAWEI.txt",Forreading, False) 'IP文件
     crt.Screen.Synchronous = True
     DO While file1.AtEndOfStream <> True
        line = file1.ReadLine
        params = Split (line)
       crt.session.LogFileName = "D:\2018\" & params(3) & ".txt"
       crt.session.Log(true)
        crt.Session.Connect "/TELNET " & params(0) '登录类型
			crt.Screen.WaitForString "Username:"
				crt.Screen.Send params(1) & vbcr
					crt.Screen.WaitForString "Password:"
						crt.Screen.Send params(2) & vbcr
        str1 = "display current-configuration"
	crt.Screen.Send str1 & vbcr'
  crt.Screen.Send "                                                   "
crt.Screen.waitForString  "return"
        crt.Session.Disconnect
        loop
     crt.Screen.Synchronous = False  
			msgbox "Backup complete " 		
End Sub

需要自己建立IP文件,格式为:

ip地址 用户名 密码 配置文件名称

你可能感兴趣的:(Windows)