| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 649 人关注过本帖
标题:请教,如何在运行中VBS输入命令并执行
只看楼主 加入收藏
huntercj
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2013-6-8
收藏
 问题点数:0 回复次数:0 
请教,如何在运行中VBS输入命令并执行
@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}"  
搜索更多相关主题的帖子: 如何 
2013-06-08 19:31
快速回复:请教,如何在运行中VBS输入命令并执行
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.049019 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved