无忧启动论坛

 找回密码
 注册
搜索
系统gho:最纯净好用系统下载站投放广告、加入VIP会员,请联系 微信:wuyouceo
查看: 3039|回复: 2
打印 上一主题 下一主题

[求助] 请教,怎么在VBS运行telnet输入命令后并执行

[复制链接]
跳转到指定楼层
1#
发表于 2013-6-8 19:18:11 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
@echo off
echo set sh=WScript.CreateObject("WScript.Shell") >telnet_tmp.vbs
echo WScript.Sleep 300 >>telnet_tmp.vbs
echo sh.SendKeys "open 192.168.1.1" >>telnet_tmp.vbs
echo WScript.Sleep 300 >>telnet_tmp.vbs
echo sh.SendKeys "{ENTER}" >>telnet_tmp.vbs
echo WScript.Sleep 300 >>telnet_tmp.vbs
echo sh.SendKeys "c3650{ENTER}">>telnet_tmp.vbs
echo WScript.Sleep 300 >>telnet_tmp.vbs
echo sh.SendKeys "en{ENTER}">>telnet_tmp.vbs
echo WScript.Sleep 300 >>telnet_tmp.vbs
echo sh.SendKeys "c3650{ENTER}">>telnet_tmp.vbs
echo WScript.Sleep 300 >>telnet_tmp.vbs
echo sh.SendKeys "config term{ENTER}" >>telnet_tmp.vbs
echo WScript.Sleep 300 >>telnet_tmp.vbs
echo sh.SendKeys "ip access-list standard web{ENTER}" >>telnet_tmp.vbs

echo Dim ip >>telnet_tmp.vbs
echo ip = inputbox("把IP输进去","请注意") >>telnet_tmp.vbs

echo WScript.Sleep 300 >>telnet_tmp.vbs
echo sh.SendKeys "exit{ENTER}" >>telnet_tmp.vbs
echo WScript.Sleep 300 >>telnet_tmp.vbs
echo sh.SendKeys "exit{ENTER}" >>telnet_tmp.vbs
echo WScript.Sleep 300 >>telnet_tmp.vbs
echo sh.SendKeys "exit{ENTER}" >>telnet_tmp.vbs
echo WScript.Sleep 300 >>telnet_tmp.vbs
echo set ws=createobject("wscript.shell") >>telnet_tmp.vbs
echo   ws.run "taskkill /f /im ping.exe",hide >>telnet_tmp.vbs
echo WScript.Sleep 300 >>telnet_tmp.vbs
echo set ws=createobject("wscript.shell") >>telnet_tmp.vbs
echo   ws.run "taskkill /f /im telnet.exe",hide >>telnet_tmp.vbs
echo sh.SendKeys "quit{ENTER}" >>telnet_tmp.vbs
start telnet
cscript //nologo telnet_tmp.vbs

最近用批出做了一个思科交换机公司电脑上网权限的脚本,想实现执行过程中手动输入 permit 192.168.1.197 就开放指定IP的上网权限,现在输入后无法执行,就是上面代码空行那里,请教各位高手要怎么改,谢谢!

Vbs

set sh=WScript.CreateObject("WScript.Shell")  
WScript.Sleep 300  
sh.SendKeys "open 192.168.1.1"  
WScript.Sleep 300  
sh.SendKeys "{ENTER}"  
WScript.Sleep 300  
sh.SendKeys "c3650{ENTER}"
WScript.Sleep 300  
sh.SendKeys "en{ENTER}"
WScript.Sleep 300  
sh.SendKeys "c3650{ENTER}"
WScript.Sleep 300  
sh.SendKeys "config term{ENTER}"  
WScript.Sleep 300  
sh.SendKeys "ip access-list standard web{ENTER}"  
Dim ip  
ip = inputbox("把IP输进去","请注意")  
WScript.Sleep 300  
sh.SendKeys "exit{ENTER}"  
WScript.Sleep 300  
sh.SendKeys "exit{ENTER}"  
WScript.Sleep 300  
sh.SendKeys "exit{ENTER}"  
WScript.Sleep 300  
set ws=createobject("wscript.shell")  
  ws.run "taskkill /f /im ping.exe",hide  
WScript.Sleep 300  
set ws=createobject("wscript.shell")  
  ws.run "taskkill /f /im telnet.exe",hide  
sh.SendKeys "quit{ENTER}"  
2#
发表于 2013-6-9 09:26:27 | 只看该作者
这样?
  1. echo Dim ip >>telnet_tmp.vbs
  2. echo ip = inputbox("把IP输进去","请注意") >>telnet_tmp.vbs
  3. echo WScript.Sleep 300 >>telnet_tmp.vbs
  4. echo sh.SendKeys ip ^& "{ENTER}" >>telnet_tmp.vbs
  5. echo WScript.Sleep 300 >>telnet_tmp.vbs
复制代码
回复

使用道具 举报

3#
发表于 2013-7-9 10:37:33 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|捐助支持|无忧启动 ( 闽ICP备05002490号-1 )

闽公网安备 35020302032614号

GMT+8, 2024-11-24 05:33

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表