本帖最后由 tmplinshi 于 2011-7-26 18:06 编辑
回复 8# wrz99
请问你用的是什么系统?竟然 reg query 的输出与 XP SP2 的不同,XP SP2 下的输出是这样的:- 空行
- ! REG.EXE VERSION 3.0
- 空行
- HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\PCI\VEN_10EC&DEV_8139&SUBSYS_813910EC&REV_10\4&29817089&0&08F0
- Driver REG_SZ {4D36E972-E325-11CE-BFC1-08002BE10318}\0001
- 空行
复制代码 再试试:- @echo off
- setlocal
-
- devcon.exe hwids PCI\CC_0200 >c:\网卡ID.txt
-
- set /p var=<c:\网卡ID.txt
-
- :: 搜索注册表
- set Driver=
- set RegPath="HKLM\SYSTEM\ControlSet001\Enum\PCI\%var:*PCI\=%"
- for /f "tokens=*" %%a in ('reg query %RegPath% /v Driver') do (
- set Driver=%%~na
- )
-
- if not defined Driver (
- echo 获取 Driver 失败。按任意键退出...
- pause >nul
- exit /b
- ) else (
- set Driver
- )
-
- :: 修改 reg 文件
- for /f "tokens=2,3,5 delims=\&" %%a in ("%var%") do (
- set RegFile="D:\网卡优化\%%a&%%b&%%c.reg"
- )
- set SearchStr=HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class
- set SearchStr=%SearchStr%\{4D36E972-E325-11CE-BFC1-08002bE10318}\
- type %RegFile% | findstr /n .* >.tmp
- (
- for /f "delims=" %%a in (.tmp) do (
- set var=%%a
- setlocal enabledelayedexpansion
- if "!var:%SearchStr%=!" neq "!var!" (
- set var=!var:\%%~na=\%Driver%!
- )
- echo,!var:*:=!
- endlocal
- )
- ) >%RegFile%
- del .tmp
-
- regedit /s %RegFile%
-
- pause
复制代码
|