标题: [注册表类] [分享]批处理获取注册表指定网卡对应的MAC地址 [打印本页]
作者: Batcher 时间: 2024-5-28 17:47 标题: [分享]批处理获取注册表指定网卡对应的MAC地址
【问题描述】
求个检索HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}位置网卡关键字DriverDesc=VirtNet Network Adapter (NDIS 6.0)的子项,修改VirtNetMacAddress为指定值的bat
不一定是0019
"VirtNetMacAddress"=hex:01,02,03,04,05,06
作者: Batcher 时间: 2024-5-28 17:49
解决方案-1.bat- @echo off
- set "FileTmp=%temp%\out.txt"
- reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}" /s > "%FileTmp%"
- for /f "delims=:" %%a in ('findstr /n /c:"DriverDesc REG_SZ VirtNet Network Adapter (NDIS 6.0)" "%FileTmp%"') do (
- call :FindMac %%a
- )
- pause
- exit /b
-
- :FindMac
- for /f "skip=%1 tokens=1-3" %%a in ('type "%FileTmp%"') do (
- if "%%a" == "VirtNetMacAddress" (
- echo %%c
- exit /b
- )
- )
复制代码
作者: Batcher 时间: 2024-5-28 17:49
解决方案-2-不使用临时文件.bat- @echo off
- for /f "delims=:" %%a in ('reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}" /s ^| findstr /n /c:"DriverDesc REG_SZ VirtNet Network Adapter (NDIS 6.0)"') do (
- call :FindMac %%a
- )
- pause
- exit /b
-
- :FindMac
- for /f "skip=%1 tokens=1-3" %%a in ('reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}" /s') do (
- if "%%a" == "VirtNetMacAddress" (
- echo %%c
- exit /b
- )
- )
复制代码
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |