回复 10# 花开花落
改一下batman的代码就是这样咯:- @echo off&setlocal enabledelayedexpansion
- for /f "delims=" %%a in ('ipconfig /all') do (
- set "str=%%a"
- if defined flag if "!str:IP Address=!" neq "!str!" set "ip=!str:*:=!"&goto next
- if "!str:本地连接=!" neq "!str!" set "flag=a"
- )
- :next
- (for /f "tokens=1* delims=:" %%a in ('findstr /n .* a.ini') do (
- set "str=%%b"
- if /i "!str:~,5!"=="Host=" set "str=Host=%ip%"
- if /i "!str:~,5!"=="addr=" set "str=addr=%ip%"
- echo,!str!
- ))>$
- move /y $ a.ini&start a.ini
复制代码 不过,呵呵,获取IP地址和修改ini文件,我还是倾向于使用现成的函数,如au3里两行代码即可:- IniWrite("a.ini","ICPreSell","addr",@IPAddress1)
- IniWrite("a.ini","Hosts","Host",@IPAddress1)
复制代码
|