批量删除windows隐藏的com口
# cleanup_coms.ps1
$env:DEVMGR_SHOW_NONPRESENT_DEVICES=1
$ghostComDevices = Get-PnpDevice | Where-Object { $_.Class -eq 'Ports' -and $_.Status -eq 'Unknown' }
foreach ($device in $ghostComDevices) {
Write-Output "Removing device: $($device.Name) with InstanceId: $($device.InstanceId)"
devcon.exe remove "@$($device.InstanceId)"
}
Write-Output "Removal process completed."
需要WDK中的devcon.exe,或从其他途径获取
浙公网安备 33010602011771号