|
modiip吧,找不到官方网站在哪里
大家能帮我完善一下扫描局域网mac地址并转换成modiip
这里有生成mac.ini的方法
http://www.cn-dos.net/forum/viewthread.php?tid=42427
但是似乎这东东不能在多网卡环境正常运行,它要求修改的网卡为"本地连接",似乎是这样的若为别的名字则无法成功.借助7zip生成自删除包放在%allusersprofile%的启动项就可以了.至于其它的基于批处理的方法则不知道是否真的是根据mac来修改的没尝试过.
以前google时有人发布在maxdos的代码
@ECHO OFF
@cls
ECHO ::::::::::::::::::::::::::::::::::::::::::::::::::::
ECHO :: GHOST完成后根据网卡MAC自动设置机名和IP的批处理 ::
ECHO ::::::::::::::::::::::::::::::::::::::::::::::::::::
::::清空环境变量
Set IPAddress=
Set strMac=
Set MacAddress=
Set CName=
Set scfile=
Set sc=
Set MacWMIC=
Set ConnName=
If not "%1"=="run" Goto setboot
cd/d %temp%
REM ::::请手动修改列表
ECHO [ComputerName] [MacAddress] [IPAddress] >iplist.txt
ECHO dato 00-0A-E6-93-9B-15 192.168.1.2 >>iplist.txt
ECHO LX002 00-04-01-02-09-91 192.168.1.2 >>iplist.txt
ECHO LX003 00-04-01-02-09-92 192.168.1.3 >>iplist.txt
ECHO LX004 00-04-01-02-09-93 192.168.1.4 >>iplist.txt
ECHO LXASP 00-03-FF-93-39-9F 192.168.0.10 >>iplist.txt
REM ::::请手动修改子网掩码
Set mask=255.255.255.0
REM ::::请手动修改默认网关
Set gway=192.168.1.1
ECHO :::: 开始查找网卡 ::::
::::获取机器的TCP/IP 配置
if exist ipconfig.txt del ipconfig.txt
ipconfig /all >ipconfig.txt
::::分离出机器的物理地址,并保存到 ( phyaddr.txt) 文件中
if exist phyaddr.txt del phyaddr.txt
if exist phyaddr1.txt del phyaddr1.txt
find "Physical Address" ipconfig.txt >phyaddr.txt
Set sc=1
Set scfile=phyaddr.txt
goto scan
::::多网卡时,扫描每个网卡MAC地址
:rescan1
Set sc=%sc%1
Set scfile=phyaddr1.txt
find /v "%strMac%" phyaddr.txt >%scfile%
Goto scan
:rescan2
Set sc=%sc%1
Set scfile=phyaddr.txt
find /v "%strMac%" phyaddr1.txt >%scfile%
Goto scan
:scan
::::从(c:\phyaddr.txt)文件中取得物理地址字符串,并赋给变量"MacAddress"
for /f "skip=2 tokens=12" %%M in (%scfile%) do set strMac=%%M
::::以变量"strMac"为关键字搜索(iplist.txt)中相同的字符串行,并保存到(PCCfg.txt)
find "%strMac%" iplist.txt >PCCfg.txt
::::找出机器名(从"PCCfg.txt"中分离出 机器名字段,并赋给变量"CName")
for /f "skip=2 tokens=1" %%N in (PCCfg.txt) do set CName=%%N
if not "%CName%"=="" Goto found
::::支持最多扫描5个网卡
If "%sc%"=="11111" Goto failed
If "%sc%"=="1" Goto rescan1
if %scfile%==phyaddr.txt Goto rescan1
if %scfile%==phyaddr1.txt Goto rescan2
:found
ECHO 本机 MAC: %strMac%
ECHO 目标名称: %CName%
::::显示IP地址. (从"PCCfg.txt"中分离出 IP地址字段,并赋给变量"IPAddress")
for /f "skip=2 tokens=3" %%I in (PCCfg.txt) do set IPAddress=%%I
ECHO 目标地址: %IPAddress%
::::显示网卡MAC地址.(从"PCCfg.txt"中分离出 MAC地址字段,并赋给变量"MacAddress")
for /f "skip=2 tokens=2" %%M in (PCCfg.txt) do set MacAddress=%%M
ECHO 目标 MAC: %MacAddress%
::::创建注册表文件
::::用变量"%CName%"去替换实际的机器名
ECHO Windows Registry Editor Version 5.00 >PCName.reg
ECHO.>>PCName.reg
ECHO [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName] >>PCName.reg
ECHO "ComputerName"="%CName%" >>PCName.reg
ECHO.>>PCName.reg
ECHO [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters] >>PCName.reg
ECHO "NV Hostname"="%CName%" >>PCName.reg
ECHO "Hostname"="%CName%" >>PCName.reg
ECHO :::: 正在更改设置 ::::
REM ::::导入注册表文件。用的时候把" :: "去掉
regedit /s PCName.reg
::::找出MAC地址所对应的连接名称
for /f "tokens=1,2,3,4,5,6 delims=-" %%A in ("%MacAddress%") do set MacWMIC=%%A:%%B:%%C:%%D:%%E:%%F
WMIC NIC WHERE "MACAddress='%MacWMIC%' AND NetConnectionID!=NULL" GET NetConnectionID /value >phyaddr.txt
WMIC NIC WHERE "MACAddress='%MacWMIC%' AND NetConnectionID!=NULL" GET NetConnectionID /value >phyaddr.txt
Type phyaddr.txt >phyaddr1.txt
for /f "skip=2 tokens=2* delims==" %%A in (phyaddr1.txt) do set ConnName=%%A
Echo 连接名称: %ConnName%
REM ::::修改IP地址。用的时候把" :: "去掉
netsh interface ip set address name="%ConnName%" source=static addr=%IPAddress% mask=%mask% gateway=%gway% gwmetric=1
ECHO :::: 准备重启 ::::
setlocal
::::删除临时文件
echo [version] > ipdel.inf
echo signature=$chicago$ >> ipdel.inf
echo [defaultinstall] >> ipdel.inf
echo delfiles=delfiles1 >> ipdel.inf
echo delfiles=delfiles2 >> ipdel.inf
echo [destinationdirs] >> ipdel.inf
echo delfiles1=16391 >> ipdel.inf
echo delfiles2=01 >> ipdel.inf
echo [delfiles1] >> ipdel.inf
echo ip.lnk,,,1 >> ipdel.inf
echo [delfiles2] >> ipdel.inf
echo PCCfg.txt,,,1 >> ipdel.inf
echo PCName.reg,,,1 >> ipdel.inf
echo ipconfig.txt,,,1 >> ipdel.inf
echo iplist.txt,,,1 >> ipdel.inf
echo phyaddr1.txt,,,1 >> ipdel.inf
echo phyaddr.txt,,,1 >> ipdel.inf
RUNDLL32.EXE SETUPAPI.DLL,InstallHinfSection DefaultInstall 128 .\ipdel.inf
del ipdel.inf
::::准备重启的文件
echo [version] > reboot.inf
echo signature=$chicago$ >> reboot.inf
echo [defaultinstall] >> reboot.inf
REM ::::立即重启。用的时候把" :: "去掉
::RUNDLL32.EXE SETUPAPI.DLL,InstallHinfSection DefaultInstall 1 .\reboot.inf
del reboot.inf
Goto end
:setboot
Echo [Version] >ipstart.inf
Echo Signature="$CHICAGO$" >>ipstart.inf
Echo [DefaultInstall] >>ipstart.inf
Echo UpdateInis = AddLink >>ipstart.inf
Echo [AddLink] >>ipstart.inf
Echo setup.ini, progman.groups,, "group1=""%%16391%%""" >>ipstart.inf
Echo setup.ini, group1,,"""IP"",""""""%%01%%\ip.bat"""" run"",,,,"""",""ip.bat""" >>ipstart.inf
RUNDLL32.EXE SETUPAPI.DLL,InstallHinfSection DefaultInstall 128 .\ipstart.inf
del ipstart.inf
Echo 完成在“开始”菜单的“启动”中创建快捷方式。
Echo 请在此之后使用GHOST创建此分区的GHO镜像文件。
pause
Goto End
:failed
ECHO !!!! 查找网卡失败 !!!!
:end |
|