这样就比较好理解了,vbs是可以获取本机ip地址的,对这段代码增加即修改如下(没有调试环境,不能保证正确)
Set WshShell = CreateObject("WScript.Shell")
Dim CloseTime,i
CloseTime = 3
For i = CloseTime To 1 Step - 1
WshShell.popup "当前时间为" & i,1,"计时",0
Wscript.Sleep 1000
next
'上段命令,开启后倒计时,时间为closetime的值。默认为零,不弹出倒计时窗口。'
dim ta,shell,j,showtime,ip()
showtime =1
'定义变量,赋值。 j,showtime,变量用于下面的提示框弹出函数。
'此处为增加的代码,
Dim objWMIService,colItems,objItem,objAddress
Set objWMIService = GetObject("winmgmts://" & ComputerName & "/root/cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objItem in colItems
For Each objAddress in objItem.IPAddress
If objAddress <> "" then
Exit For
End If
Next
Exit For
Next
If objAddress="" then
msgbox "没有网卡,终止执行"
wscript.quit
endif
ip=split(objAddress,".")
'已经获取本机ip地址放到数组ip(0)至ip(3)中
set shell=wscript.createobject("wscript.shell")
shell.appactivate"115200"
shell.SendKeys "setenv serverip " & ip(0) & "." & ip(1) & "." & ip(2) & ".224"
WScript.Sleep 400
shell.appactivate"115200"
shell.SendKeys "{ENTER}"
WScript.Sleep 600
shell.appactivate"115200"
shell.SendKeys "setenv ipaddr " & ip(0) & "." & ip(1) & "." & ip(2) & ".225"
WScript.Sleep 500
shell.appactivate"115200"
shell.SendKeys "{ENTER}"
WScript.Sleep 600
shell.appactivate"115200"
shell.SendKeys "save"
WScript.Sleep 200
shell.appactivate"115200"
shell.SendKeys "{ENTER}"
WScript.Sleep 200
shell.appactivate"115200"
shell.SendKeys"protect off all"
WScript.Sleep 300
shell.appactivate"115200"
shell.SendKeys "{ENTER}"
WScript.Sleep 4600
shell.appactivate"115200"
shell.SendKeys"erase all"
WScript.Sleep 200
shell.appactivate"115200"
shell.SendKeys "{ENTER}"
WScript.Sleep 10000
shell.appactivate"115200"
MSGBOX("请务必在擦除完成后再点击确定")
shell.appactivate"115200"
shell.SendKeys "{ENTER}"
WScript.Sleep 200
WScript.Sleep 500
shell.appactivate"115200"
shell.SendKeys "tftp 0x80000000 6004-sz.bin"
WScript.Sleep 100
shell.appactivate"115200"
shell.SendKeys "{ENTER}"
WScript.Sleep 5000
shell.appactivate"115200"
MSGBOX("请务必在写完后再点击确定")
WScript.Sleep 200
shell.appactivate"115200"
shell.SendKeys "re"
WScript.Sleep 200
shell.appactivate"115200"
shell.SendKeys "{ENTER}"
WScript.Sleep 1000