1 windows windows-registry bluetooth drivers windows-10
我有一台运行 Windows 10 的机器。
我正在尝试删除蓝牙设备并重新连接它。一开始,当我尝试通过 Windows 设置删除设备时,收到“删除失败”的消息。当我尝试通过控制面板删除它时,发生了同样的事情。
我在设备管理器中删除了该设备的驱动程序,但重新启动后,该设备仍然存在。但该驱动程序未在设备管理器中列出。
我采取的最后一步是删除注册表文件中该设备的条目,但重新启动后该设备仍然存在。目前注册表文件中没有条目。我把它从:
HKLM\SYSTEM\CurrentControlSet\Services\BTHPORT\Parameters\Devices
Run Code Online (Sandbox Code Playgroud)
现在,我在 Windows 设置和控制面板的“设备和打印机”部分中看到了该设备,但无法删除其中任何一个。注册表中没有该设备的条目,也没有该设备的驱动程序。在删除该条目之前,我也没有注册表的备份。
我如何摆脱这个东西以便我可以重新连接它?该设备是一副耳机,所以我经常使用它。
您可以尝试使用此API 的PowerShell包装器BluetoothRemoveDevice()。将以下代码复制并粘贴到PowerShell窗口中,然后按Enter:
$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 found ********" | Write-Host
}
} While (($BTDevices = @(Get-BTDevice)) -and [int]$selected)
Run Code Online (Sandbox Code Playgroud)
运行时,它将列出蓝牙设备:
PS > . "C:\Users\keith\Sandbox\Bluetooth Removal\removedevice v1.0.ps1"
******** Bluetooth Devices ********
1 - Chill Out
2 - LG HBS730
Select a device to remove (0 to Exit):
Run Code Online (Sandbox Code Playgroud)
如果该设备未在那里列出,我猜它是命名空间工件。
| 归档时间: |
|
| 查看次数: |
7806 次 |
| 最近记录: |