找回密码
 加入
搜索
查看: 2639|回复: 4

[AU3基础] 请问这个BAT 内容换成 autoit 是如何表达呢

  [复制链接]
发表于 2012-3-29 14:25:52 | 显示全部楼层 |阅读模式
@echo off
for /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%
发表于 2012-3-30 13:35:59 | 显示全部楼层
回复 2# zxxputian6

有循环的bat,还要查找,可能工具转不了
发表于 2012-3-30 13:57:13 | 显示全部楼层
回复  zxxputian6

有循环的bat,还要查找,可能工具转不了
happytc 发表于 2012-3-30 13:35


肯定转不了.
但可以运行相关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[0]
        
        $iIP = StringRegExp($sText,'(?:IP\D+)(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})', 3)
        If IsArray($iIP) Then $IPAddress = $iIP[0]
        
        $iSM = StringRegExp($sText,'(?:Sub\D+)(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})', 3)
        If IsArray($iSM) Then $SubMask = $iSM[0]
        
        $iGW = StringRegExp($sText,'(?:Default\D+)(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})', 3)
        If IsArray($iGW) Then $GateWay = $iGW[0]
        
        $iDns = StringRegExp($sText,'(?:DNS\D+)(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})', 3)
        If IsArray($iDns) Then $DNS1 = $iDns[0]
        
        $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[0]
            
                IniWrite($tmpfile, '配置', '机器名称', $CName)
                IniWrite($tmpfile,'配置', 'IP地址', $IpAddress)
                IniWrite($tmpfile,'配置', '子网掩码', $SubMask)
                IniWrite($tmpfile,'配置', '默认网关', $GateWay)
                IniWrite($tmpfile,'配置', '首选DNS', $DNS1)
                IniWrite($tmpfile,'配置', '备用DNS', $DNS2)
EndFunc
发表于 2012-4-27 13:42:35 | 显示全部楼层
难度相当大 简单的是可以转
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-8 05:58 , Processed in 0.072610 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表