Skip to content

Instantly share code, notes, and snippets.

@winkler-winsen
Last active July 10, 2025 15:12
Show Gist options
  • Select an option

  • Save winkler-winsen/c7b4ccede0ca777fbb58aca8f6431e70 to your computer and use it in GitHub Desktop.

Select an option

Save winkler-winsen/c7b4ccede0ca777fbb58aca8f6431e70 to your computer and use it in GitHub Desktop.
Reset Windows COM port settings and remove hidden / non active devices
# Reset Windows COM port settings
# 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\COM Name Arbiter' ComDB
# Reset bitmask of unused comports. e.g. 0x03 (=00000011) for COM1 + COM2 used for motherboard
# https://ftdichip.com/wp-content/uploads/2020/08/AN_132_Re-Assigning_COM_Port_Numbers_Using_Registry.pdf
$path='HKLM:\SYSTEM\CurrentControlSet\Control\COM Name Arbiter'
Set-ItemProperty -Path $path -Name ComDB -Value ([byte[]](0x00)) -Verbose
# 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports'
$path='HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports'
Get-ItemProperty $path | Get-Member -MemberType NoteProperty | where Name -like 'COM*' | foreach { Remove-ItemProperty -Path $path -Name $_.Name -Verbose }
# remove PnP devices "Name (COM*)"
Get-PnpDevice | Where -FilterScript { $_.Class -EQ 'Ports' -and $_.FriendlyName -match '(COM[\d.])' } | % { & "pnputil.exe" /remove-device $_.InstanceId }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment