请问这个BAT 内容换成 autoit 是如何表达呢
@echo offfor /f "tokens=2 delims=:" %%a in ('ipconfig /all^|find "IP Address"') do set local_ip=%%a
for /f "tokens=2 delims=:" %%b in ('ipconfig /all^|find "Physical Address"') do set local_mac=%%b
arp -s %local_ip% %local_mac%
for /f "tokens=2 delims=:" %%c in ('ipconfig /all^|find "Default Gateway"') do set gate_ip=%%c
ping %gate_ip% -n 3>nul
for /f "skip=3 tokens=2" %%d in ('arp -a %gate_ip%') do set gate_mac=%%d
arp -s %gate_ip% %gate_mac% 回复 2# zxxputian6
有循环的bat,还要查找,可能工具转不了 回复zxxputian6
有循环的bat,还要查找,可能工具转不了
happytc 发表于 2012-3-30 13:35 http://www.autoitx.com/images/common/back.gif
肯定转不了.
但可以运行相关DOS命令后截取回显, 然后用正则获取IP;网关等值
最后又是运行Arp 绑定的Dos命令.
如果按行来算, 多了几倍.
以下是我写过的截取 IPCONFIG /ALL 命令的一个函数,
楼主参考下吧, 求完整代码有点过份,不现实!Func _LocateData() ;读取当前系统的网络配置
local $sText, $iPID
$iPID = Run(@ComSpec & " /c ipconfig /all", '', @SW_HIDE, 6)
While 1
$sText &= StdoutRead($iPID)
If @error Then ExitLoop
WEnd
$iName = StringRegExp($sText,'(?:Host Name\W+)(\w+)', 3)
If IsArray($iName) Then $CName = $iName
$iIP = StringRegExp($sText,'(?:IP\D+)(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})', 3)
If IsArray($iIP) Then $IPAddress = $iIP
$iSM = StringRegExp($sText,'(?:Sub\D+)(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})', 3)
If IsArray($iSM) Then $SubMask = $iSM
$iGW = StringRegExp($sText,'(?:Default\D+)(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})', 3)
If IsArray($iGW) Then $GateWay = $iGW
$iDns = StringRegExp($sText,'(?:DNS\D+)(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})', 3)
If IsArray($iDns) Then $DNS1 = $iDns
$iDns2 = StringRegExp($sText,'(?:DNS\D+\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\v*\h*)(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})', 3)
If IsArray($iDns2) Then $DNS2 = $iDns2
IniWrite($tmpfile, '配置', '机器名称', $CName)
IniWrite($tmpfile,'配置', 'IP地址', $IpAddress)
IniWrite($tmpfile,'配置', '子网掩码', $SubMask)
IniWrite($tmpfile,'配置', '默认网关', $GateWay)
IniWrite($tmpfile,'配置', '首选DNS', $DNS1)
IniWrite($tmpfile,'配置', '备用DNS', $DNS2)
EndFunc 难度相当大 简单的是可以转
页:
[1]