- rem 单网卡(Intel 21140-Based PCI Fast Ethernet Adapter (Generic))、XPSP3下测试通过
- @echo off
- pushd "%~dp0\"
- SetLocal EnableDelayedExpansion
-
- rem 下面两行请自行修改
- set NetConnectionID=本地连接
- set NetworkAddress=111122223333
-
- set Fullkey="HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class"
-
- rem 获取“本地连接”的设备名称
- for /f "delims=" %%a in ('wmic nic where "netconnectionid='%NetConnectionID%'" get name /value') do call set %%a>nul 2>nul
-
- regedit.exe /e %temp%\clsid.reg %Fullkey%
-
- rem 分析注册表
- echo.正在分析注册表文件...
- for /f "delims=:" %%a in ('Type "%temp%\clsid.reg" ^| findstr /ni /c:"%name%"') do (
- for /l %%i in (100,-1,1) do (
- set /a Line = %%a - %%i
- for /f "tokens=2 delims=:" %%b in ('Type "%temp%\clsid.reg" ^| findstr /n .* ^| findstr /b !Line!:') do (
- echo.%%b | findstr /i %Fullkey% >nul 2>nul
- if !errorlevel! == 0 set CLSID=%%b
- )
- )
- )
-
- rem 使用reg add命令修改物理地址
- reg add "%CLSID:~1,-1%" /v NetworkAddress /d %NetworkAddress% /f
-
- rem 禁用网卡
- netsh interface set interface "本地连接" disable
-
- rem 启用网卡
- netsh interface set interface "本地连接" enable
-
- erase "%temp%\clsid.reg"
- echo.按任意键退出...
- pause >nul
复制代码 不过,我不敢保证 netsh 能启用、禁用网卡... |