Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Batch operation under window: call vbs in bat file

Shulou Source: shulou.com Published: 2022-06-03 05:28:41 10月05日 Update

@ echo "kill CRT process" taskkill / F / IM SecureCRT.exe::ping 127.0.0.1-n 30echo "start vos through CRT" echo offd:cd D:\ tools\ SecureCRT_x86start SecureCRT.EXE / SCRIPT D:\ Secure_vos\ Start_vos.vbsecho "start vos through CRT end" ping 127.0.0.1-n 4pause

The above code means: execute the Start_vos.vbs file in the .bat file

You first need to download the SecureCRT.exe file before batch execution.

The Start_vos.vbs file is as follows:

# $language = "VBScript" # $interface = "1.0" crt.Screen.Synchronous = TrueSub 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

The above code is mainly used to automate the manual input process using VBS scripts.

First of all:

Set objtab = crt.Session.ConnectInTab ("/ SSH2 / PASSWORD root123 root@172.11.1.15", True)

Connect the linuxIP address by SSH2

172.21.1.114, password is root123, user name is rootobjtab.caption = "Start_vos"

Rename the current connection page to Start_vos

Crt.Screen.Send "cd / home/test" & chr (13) enter cd / home/test and enter enter

Crt.Screen.WaitForString chr (27) & "[32m (none) / home/test" & chr (27) & "[m #" waiting for the next line of the page is chr (27) & "[32m (none) / home/test" & chr (27) & "[m #"

Tags: File code content page input line address password meaning manual method user user name script process automation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Shulou Technology Apple Xiaomi NVidia