Tag Archives: registry

Batch code snippet to query, then update dynamic values in registry

By | September 21, 2016
Share

FOR /F “tokens=1,2*” %%a in (‘reg.exe query “HKLM\SYSTEM\CurrentControlSet\Control\Class”‘) DO call :FindAndReplace %%a goto cleanup :FindAndReplace reg.exe query “%1\0000” /f “COM3” /d > nul if “%ErrorLevel%”==”0” reg.exe add “%1\0000” /v “AttachedTo” /t REG_SZ /d “COM1” /f exit /b :cleanup echo “This is a test” pause The snippet pulls sub-keys from the “HKLM\SYSTEM\CurrentControlSet\Control\Class” and passing each to a… Read More »