![]() |
中国DOS联盟-- 联合DOS 推动DOS 发展DOS --联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum |
| 游客 | 登录 | 注册 | 会员 | 搜索 | 中国DOS联盟 |
|
中国DOS联盟论坛 现在时间是 2026-08-11 09:45 |
共 47,811 主题排行 / 349,897 发帖 / 今日 0 篇 / 48,256 会员排行 |
| DOS批处理 & 脚本技术(批处理室) » 如何实现用批处理输入特定字符并回车执行 |
| 可打印版本 891 / 1 |
| 第1楼 jasonwang | 发表于 2009-02-18 00:22 |
| 初级用户 发帖 54 积分 122 | |
|
如何实现用批处理输入特定字符并回车执行 我现在有这样一个需求,如何来实现:
1. 用PING命令,PING IP,如果目标设备存在 2. 输入TELNET IP 3. 出现USER提示后:输入帐号 4. 出现PASSWORD后: 输入密码 5. 出现#号提示符后: 输入REBOOT 6. 循环第1步,直到IP地址为254为止 |
|
| 第2楼 scriptor | 发表于 2009-02-19 00:52 |
| 银牌会员 发帖 555 积分 1,187 | |
Originally posted by jasonwang at 2009-2-18 00:22: @echo off rem AutoTlnt.bat rem Auto Detect and Telnet the remote machines, then reboot them rem Version 1.0.0.0 rem Copyright 2009-2010 Scriptor (Scriptor@www.cn-dos.net) rem Created at 23:28 2009年2月18日 rem ============================================================ rem Before you can go on, please read this REM carefully. rem ~ stand for ENTER; rem Modify the IP address you wana test; rem Modify the Username and password to connect the remote machine. rem NOTE: No Permission for Abusing of this script. rem ============================================================ for /l %%a in (1,1,254) do ( ping -n 2 192.168.1.%%a|find /i "ttl" ( echo set sh=WScript.CreateObject("WScript.Shell") >tlnt%%a.vbs echo WScript.Sleep 300 >>tlnt%%a.vbs echo sh.SendKeys "open 192.168.1.%%a ~" >>tlnt%%a.vbs echo WScript.Sleep 500 >>tlnt%%a.vbs echo sh.SendKeys "Username ~" >>tlnt%%a.vbs echo WScript.Sleep 400 >>tlnt%%a.vbs echo sh.SendKeys "Password ~">>tlnt%%a.vbs echo WScript.Sleep 500 >>tlnt%%a.vbs echo sh.SendKeys "reboot ~">>tlnt%%a.vbs start telnet cscript //nologo tlnt%%a.vbs del tlnt%%a.vbs ) ) |
|
|
[ 联系联盟系统管理团队 -
中国DOS联盟 -
标准版 ] Sponsored by ifanr Inc | © 2001–2023 |