本帖最后由 pcl_test 于 2015-1-31 22:34 编辑
回复 15# kuishilova
把1.vbs、2.vbs……以相应的ip重命名- @echo off
- setlocal enabledelayedexpansion
- color a
- :wait
- cls
- echo 1、进行配置
- echo 2、退出
- set a=0
- set/p a=请选择:
- if %a%==1 goto :startconf
- if %a%==2 exit
- goto :wait
- :startconf
- echo 交换机配置结果:>>配置结果.txt
- set count=0
- for /f "delims=" %%i in (ip.txt) do (
- set temp=0
- echo 正在扫描 %%i
- echo 请等待........
- ping -n 1 -w 2 %%i|find "TTL" >nul&&set temp=1
- if "!temp!" equ "1" (
- echo 扫描%%i完成,正在执行配置工作...
- >telnet_tmp.vbs echo set sh=WScript.CreateObject^("WScript.Shell"^)
- >>telnet_tmp.vbs echo WScript.Sleep 300
- >>telnet_tmp.vbs echo sh.SendKeys "open %%i"
- >>telnet_tmp.vbs echo WScript.Sleep 1000
- >>telnet_tmp.vbs echo sh.SendKeys "{ENTER}"
- >>telnet_tmp.vbs echo WScript.Sleep 1000
- start telnet
- ping -n 2 127.1 >nul
- cscript //nologo telnet_tmp.vbs
- ping -n 2 127.1 >nul
- cscript //nologo %%i.vbs
- del telnet_tmp.vbs
- set /a count+=1
- echo %%i配置成功
- echo %%i配置成功>>配置结果.txt
- ) else (
- echo %%i无法ping通!
- echo %%i配置失败>>配置结果.txt
- )
- )
- echo ----------------结果说明---------------
- echo 配置完毕!
- echo 共配置可以联通的交换机:%count%台。
- echo 配置的结果保存在当前目录的“配置结果.txt”中。
- echo ---------------------------------------
- echo 按任意键返回主菜单
- pause>nul
- goto :wait
复制代码
|