批处理(ip地址做变量)运行有问题,高手帮忙看看啥原因

for /l 语句是(Start Step End) 要实现你的要求应该用不加开关的for 而且变量必须用%%的形式

第二个文件看起来没什么问题啊...应该是你的ip.txt格式不对,而for /f没有做相应的修正

正确代码

@echo?off?

for?%%i?in?(111?112?113)?do?(?

echo?set?sh=WScript.CreateObject("WScript.Shell")?>telnet_tmp.vbs?

echo?WScript.Sleep?300?>>telnet_tmp.vbs?

echo?sh.SendKeys?"open?192.168.%%i.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?"admin{ENTER}">>telnet_tmp.vbs?

echo?WScript.Sleep?300?>>telnet_tmp.vbs?

echo?sh.SendKeys?"ddd123{ENTER}">>telnet_tmp.vbs?

echo?sh.SendKeys?"save{ENTER}">>telnet_tmp.vbs

echo?sh.SendKeys?"y{ENTER}">>telnet_tmp.vbs

echo?sh.SendKeys?"{ENTER}"?>>telnet_tmp.vbs

echo?WScript.Sleep?300?>>telnet_tmp.vbs

echo?sh.SendKeys?"quit{ENTER}">>telnet_tmp.vbs

start?telnet?

cscript?//nologo?telnet_tmp.vbs?

echo?del?telnet_tmp.vbs

echo?WScript.Sleep?300?>>telnet_tmp.vbs

)?

pause