找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 15124|回复: 2

[注册表类] [分享]批处理获取注册表指定网卡对应的MAC地址

[复制链接]
发表于 2024-5-28 17:47:57 | 显示全部楼层 |阅读模式
【问题描述】

求个检索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
 楼主| 发表于 2024-5-28 17:49:02 | 显示全部楼层
解决方案-1.bat
  1. @echo off
  2. set "FileTmp=%temp%\out.txt"
  3. reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}" /s > "%FileTmp%"
  4. for /f "delims=:" %%a in ('findstr /n /c:"DriverDesc    REG_SZ    VirtNet Network Adapter (NDIS 6.0)" "%FileTmp%"') do (
  5.     call :FindMac %%a
  6. )
  7. pause
  8. exit /b

  9. :FindMac
  10. for /f "skip=%1 tokens=1-3" %%a in ('type "%FileTmp%"') do (
  11.     if "%%a" == "VirtNetMacAddress" (
  12.         echo %%c
  13.         exit /b
  14.     )
  15. )
复制代码
 楼主| 发表于 2024-5-28 17:49:33 | 显示全部楼层
解决方案-2-不使用临时文件.bat
  1. @echo off
  2. 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 (
  3.     call :FindMac %%a
  4. )
  5. pause
  6. exit /b

  7. :FindMac
  8. 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 (
  9.     if "%%a" == "VirtNetMacAddress" (
  10.         echo %%c
  11.         exit /b
  12.     )
  13. )
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-18 00:35 , Processed in 0.017321 second(s), 8 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表