QZLin

批量删除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,或从其他途径获取

posted on 2025-01-26 20:37  QZLin  阅读(203)  评论(0)    收藏  举报

导航