window下批处理操作:bat文件中调用vbs-创新互联
@echo "kill CRT process" taskkill /F /IM SecureCRT.exe ::ping 127.0.0.1 -n 30 echo "start vos through CRT" echo off d: cd D:\tools\SecureCRT_x86 start SecureCRT.EXE /SCRIPT D:\Secure_vos\Start_vos.vbs echo "start vos through CRT end" ping 127.0.0.1 -n 4 pause
上述代码的意思是:在.bat文件中执行Start_vos.vbs文件
我们提供的服务有:成都做网站、网站设计、微信公众号开发、网站优化、网站认证、湖北ssl等。为1000多家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的湖北网站制作公司批处理执行文件之前首先需要下载SecureCRT.exe文件
Start_vos.vbs文件内容如下:
#$language = "VBScript" #$interface = "1.0" crt.Screen.Synchronous = True Sub Main On Error Resume Next Dim result If crt.Session.Connected Then crt.Session.Disconnect ' connected to the '172.21.1.114' Set objtab = crt.Session.ConnectInTab("/SSH2 /PASSWORD root root@172.21.1.114",True) ' Capture error code and description (if any) nError = Err.Number strErr = Err.Description ' Now, tell the script host that it should handle errors as usual now: On Error Goto 0 ' change tab name objtab.caption = "Gdb_vos" ' enter the folder crt.Screen.Send "cd /home/test" & chr(13) crt.Screen.WaitForString chr(27) & "[32m(none) /home/test" & chr(27) & "[m # " End Sub
上述代码主要是将手动输入的过程使用VBS脚本进行自动化
首先:
Set objtab = crt.Session.ConnectInTab("/SSH2 /PASSWORD root123 root@172.11.1.15",True)
采用SSH2的方式连接linuxIP地址
172.21.1.114,密码是root123,用户名是root
objtab.caption = "Start_vos"
将当前连接页面重命名为Start_vos
crt.Screen.Send "cd /home/test" & chr(13)输入cd /home/test并回车
crt.Screen.WaitForString chr(27) & "[32m(none) /home/test" & chr(27) & "[m # "等待页面下一行的内容为
chr(27) & "[32m(none) /home/test" & chr(27) & "[m # "
网站题目:window下批处理操作:bat文件中调用vbs-创新互联
文章路径:http://pwwzsj.com/article/diesjp.html