Skip to content

Instantly share code, notes, and snippets.

@brianfgonzalez
Last active September 21, 2016 01:56
Show Gist options
  • Save brianfgonzalez/f8e53a934c530439656e734b725c7cf2 to your computer and use it in GitHub Desktop.
Save brianfgonzalez/f8e53a934c530439656e734b725c7cf2 to your computer and use it in GitHub Desktop.
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 "Place your clean up code here"
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment