Board logo

标题: 构思获取MAC的批处理出现的问题! [打印本页]

作者: fbi     时间: 2006-11-30 22:31    标题: 构思获取MAC的批处理出现的问题!

构思获取MAC的批处理待处理的问题!
目的:
利用DOS中的ipconfig获取MAC信息,生成一个自动跳转带MAC信息参数的.htm文件,利用这个文件把这台主机的MAC添加到服务器!

GoMAC.bat内容为:
*****************************************************
@echo off

:::::::::如果c:\macinfo.htm存在就把它删除
::if exist c:\macinfo.htm del c:\macinfo.htm

:::::::::如果c:\ipconfig.txt存在就把它删除
if exist c:\ipconfig.txt del c:\ipconfig.txt

:::::::::运行ipconfig /all命令并把其内容保存到ipconfig.txt
ipconfig /all >c:\ipconfig.txt

:::::::::如果c:\MyMAC.txt存在就把它删除
if exist c:\MyMAC.txt del c:\MyMAC.txt

:::::::::查询c:\ipconfig.txt中含有Physical Address一行,并把这行保存到c:\MyMAC.txt
find "Physical Address" c:\ipconfig.txt >c:\MyMAC.txt

::?????????待处理的问题在这一步?????????????????????????

:::::::::如果c:\ipconfig.txt存在就把它删除
if exist c:\ipconfig.txt del c:\ipconfig.txt

:::::::::如果c:\macinfo.htm存在就把它打开
if exist c:\ipconfig.txt call c:\macinfo.htm

exit
**************************************************
其中待处理的问题是:
生成的c:\MyMAC.txt内容为:
***********************************************
---------- C:\IPCONFIG.TXT
        Physical Address. . . . . . . . . : 00-13-3F-6A-54-0B
        Physical Address. . . . . . . . . : 00-13-CA-1B-B8-50
        Physical Address. . . . . . . . . : 00-53-45-00-00-00
***********************************************
1\我要把c:\MyMAC.txt内容处理为:
00-13-3F-6A-54-0B|00-13-CA-1B-B8-50|00-53-45-00-00-00

2\生成一个文件macinfo.htm的文件,其内容为:
<meta http-equiv="refresh" content="0;url=http://192.168.1.1/macinfo.php?macinfo=00-13-3F-6A-54-0B|00-13-CA-1B-B8-50|00-53-45-00-00-00

3\打开macinfo.htm

请大侠帮忙完成余下的问题吧!

谢谢!
作者: 9527     时间: 2006-12-1 02:10
@echo off&setlocal enabledelayedexpansion
for /f "tokens=1* delims=:" %%a in (tmp.txt) do (
set c=%%b
if not defined a (<nul set/p pp=!c:~1,17!>>oo.txt&set a=1) else (<nul set/p pp=!pp!^|!c:~1,17!>>oo.txt)
)
start "" oo.txt