6

我想远程登录到我的路由器,我想自动化它,这样我就不必一直登录,因为我每天要登录几次。

VBS中除了sendkeys还有其他方法吗?这是因为物理类型,所以 telnet 窗口需要激活,比较烦人。

我尝试了一个批处理文件,但我得到了非常奇怪的结果。这里是:

telnet 192.168.1.254
REM This is the router IP
ping 255.255.255.255 -n 1 -w 1000 > nul
REM This is to wait for the router if its being slow
George 
REM This is the username, as it prompts as soon as it logs in
ping 255.255.255.255 -n 1 -w 1000 > nul
(the password)
ping 255.255.255.255 -n 1 -w 1000 > nul
system
REM Enters the system menu
ping 255.255.255.255 -n 1 -w 10 > nul
debug
REM Enters the Debug menu
ping 255.255.255.255 -n 1 -w 100 > nul
:s
 cpu
 REM This lets me see the CPU usage
 ping 255.255.255.255 -n 1 -w 1000 > nul
 REM Wait while it lists it
 mem
 REM Checks the memory 
 ping 255.255.255.255 -n 1 -w 1000 > nul
 REM Waits again!
goto s
REM I need a loop otherwise I would have to type out lots of code!

结果如下:

C:\Users\George\Desktop>telnet 192.168.1.254

C:\Users\George\Desktop>telnet 192.168.1.254
^C Terminate batch job (Y/N)?

为什么要这样做?这将是我预期的结果......

Username : George
Password : *******
------------------------------------------------------------------------

                             ______  Technicolor TG582n
                         ___/_____/\
                        /         /\\  8.C.M.0.AR
                  _____/__       /  \\
                _/       /\_____/___ \  Copyright (c) 1999-2012, Technicolor
               //       /  \       /\ \
       _______//_______/    \     / _\/______
      /      / \       \    /    / /        /\
   __/      /   \       \  /    / /        / _\__
  / /      /     \_______\/    / /        / /   /\
 /_/______/___________________/ /________/ /___/  \
 \ \      \    ___________    \ \        \ \   \  /
  \_\      \  /          /\    \ \        \ \___\/
     \      \/          /  \    \ \        \  /
      \_____/          /    \    \ \________\/
           /__________/      \    \  /
           \   _____  \      /_____\/
            \ /    /\  \    /___\/
             /____/  \  \  /
             \    \  /___\/
              \____\/

------------------------------------------------------------------------
{George}=>system
{George}=>debug
{George}[system debug]=>cpu
CPU (%):    Idle     User     Kernel
           57.43     0.99    41.58
{George}[system debug]=>mem
Total:                    61280 KB
Used:                     45216 KB
  by kernel:              30748 KB
  by applications:        14468 KB
{George}[system debug]=>

那么,它为什么要这样做呢?

我可以使用除了 sendkeys 之外的其他方法吗?

4

3 回答 3

6

你可以用谷歌搜索这个工具:它不会为 windows telnet.exe 编写脚本,但它是一个可编写脚本的 telnet 客户端。


阿尔伯特耶鲁的Telnet 脚本工具 v.1.0

于 2013-07-12T22:54:41.163 回答
1

一种方法是使用一些 Windows 版本的 netcat。这里有一个例子: http ://net.tutscity.com/networking/automate-telnet-session-using-netcat/

于 2013-07-11T20:30:31.197 回答
1

Telnet 脚本工具 ( TST10 ) 很旧,但非常高效,
这里有一个现代的替代品,带有漂亮的 GUI AutoTelnet。

于 2018-05-23T20:57:19.980 回答