Windows10 无法删除蓝牙设备 解决方案
Win10下,显示已配对,但是无法正常连接,蓝牙设备还删除不了。卸载驱动后重装也不能删除设备。

上述问题,可以通过命令行来彻底删除。
在运行框里输入PowerShell(按键盘上的Win+R键,然后输入PowerShell),确认。
将下面的代码复制进去,回车键。
$Source = @"
[DllImport("BluetoothAPIs.dll", SetLastError = true, CallingConvention = CallingConvention.StdCall)]
[return: MarshalAs(UnmanagedType.U4)]
static extern UInt32 BluetoothRemoveDevice(IntPtr pAddress);
public static UInt32 Unpair(UInt64 BTAddress) {
GCHandle pinnedAddr = GCHandle.Alloc(BTAddress, GCHandleType.Pinned);
IntPtr pAddress = pinnedAddr.AddrOfPinnedObject();
UInt32 result = BluetoothRemoveDevice(pAddress);
pinnedAddr.Free();
return result;
}
"@
Function Get-BTDevice {
Get-PnpDevice -class Bluetooth |
?{$_.HardwareID -match 'DEV_'} |
select Status, Class, FriendlyName, HardwareID,
# Extract device address from HardwareID
@{N='Address';E={[uInt64]('0x{0}' -f $_.HardwareID[0].Substring(12))}}
}
################## Execution Begins Here ################
$BTR = Add-Type -MemberDefinition $Source -Name "BTRemover" -Namespace "BStuff" -PassThru
$BTDevices = @(Get-BTDevice) # Force array if null or single item
Do {
If ($BTDevices.Count) {
"`n******** Bluetooth Devices ********`n" | Write-Host
For ($i=0; $i -lt $BTDevices.Count; $i++) {
('{0,5} - {1}' -f ($i+1), $BTDevices[$i].FriendlyName) | Write-Host
}
$selected = Read-Host "`nSelect a device to remove (0 to Exit)"
If ([int]$selected -in 1..$BTDevices.Count) {
'Removing device: {0}' -f $BTDevices[$Selected-1].FriendlyName | Write-Host
$Result = $BTR::Unpair($BTDevices[$Selected-1].Address)
If (!$Result) {"Device removed successfully." | Write-Host}
Else {"Sorry, an error occured." | Write-Host}
}
}
Else {
"`n********* No devices foundd ********" | Write-Host
}
} While (($BTDevices = @(Get-BTDevice)) -and [int]$selected)
在运行结果里,选择需要删除的蓝牙设备,输入相应的数字,依次删除即可。
回到蓝牙设备列表里,如果有的话,可以再次删除设备。
PS1:以上,如果无效的话。
单击开始按钮,在程序列表里找到Windows PowerShell,右键,选择“以管理员身份运行”。
