I'm looking to create a batch file that will perform a pretty specific function:
Search the registry key "\HKLM\SYSTEM\CurrentControlSet\Control\Class{4D36E972-E325-11CE-BFC1-08002bE10318}"
Find all subkeys that contain a specific text string, in this case "Intel" in "DriverDesc" value
Change the "PnPCapabilities" value data to "38" (hex) only in the keys that contain "Intel" in "DriverDesc" value
I know how to do each of these things separately, but I'm not quite able to get them all to work together in a single batch. My knowledge of the batch language is still too limited to know how to do it properly on my own, or to decipher and modify an existing batch.
To make things less confusing, I'm trying to disable the power management options for a pair of Intel NIC cards. I'd like to make a batch that will automatically do this on any machine, regardless of what other NICs are present, or in which order they were installed.
Any help would be greatly appreciated.
The following is what I've found, tried and failed:
EDIT: New batch
EDIT2: New batch, working
:start
setlocal ENABLEDELAYEDEXPANSION
set qry=reg query "HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}" /s /v DriverDesc
for /f "Tokens=*" %%p in ('%qry%') do (
set var=%%p
set var=!var:^&=!
set var=!var:^)=!
set var=!var:^(=!
call :parse
)
endlocal
goto :EOF
:parse
if /i "%var:~0,5%" NEQ "HKEY_" goto parse1
set key=%var%
set key=%key:HKEY_LOCAL_MACHINE=HKLM%
goto :EOF
:parse1
setlocal ENABLEEXTENSIONS
for /f "Tokens=*" %%f in ('@echo %var%^|findstr /i /c:"Intel(R)"') do (
if defined key reg add %key% /v PnPCapabilities /t REG_DWORD /d 56 /f&set key=
)
endlocal >nul 2>&1
Fixed so that it does what is intended.