winget install --id=PolarGoose.BluetoothDevicePairing -e
Console utility to discover and pair Bluetooth and Bluetooth LE devices.
BluetoothDevicePairing is a console utility designed to discover, pair, connect, and manage Bluetooth and Bluetooth Low Energy (LE) devices efficiently.
Key Features:
Audience & Benefit:
Ideal for IT professionals, system administrators, developers, and anyone needing to automate Bluetooth device management. This utility simplifies the process of discovering, pairing, and managing devices without manual GUI interaction, enabling efficient automation in scripts and workflows. By using MAC addresses or adjustable discovery parameters, users can achieve faster and more reliable device management outcomes.
Installable via winget for easy setup.
Console utility to discover and pair Bluetooth and Bluetooth Low Energy devices. The utility also allows to connect and disconnect from audio Bluetooth devices.
--discovery-time
parameter to change the time spend on device discovery.Windows 10 1809 (10.0.17763) or higher
BluetoothDevicePairing.exe --help
and BluetoothDevicePairing.exe --help
to get usage information and check the Examples
section below.BluetoothDevicePairing.exe discover
BluetoothDevicePairing.exe pair-by-mac --mac 12:34:56:78:9A:BC --type Bluetooth
BluetoothDevicePairing.exe pair-by-name --name "MX Ergo" --type BluetoothLE
BluetoothDevicePairing.exe pair-by-name --name "Device name" --type BluetoothLE --pin 1234
BluetoothDevicePairing.exe pair-by-mac --mac 12:34:56:78:9A:BC --type Bluetooth --pin 1234
BluetoothDevicePairing.exe unpair-by-mac --mac 12:34:56:78:9A:BC --type Bluetooth
BluetoothDevicePairing.exe unpair-by-name --name "MX Ergo" --type BluetoothLE
BluetoothDevicePairing.exe list-adapters
BluetoothDevicePairing.exe disconnect-bluetooth-audio-device-by-name --name WH-1000XM5
BluetoothDevicePairing.exe disconnect-bluetooth-audio-device-by-mac --mac 88:c9:e8:17:5e:0f
The BluetoothDevicePairing utility can be used in bat and PowerShell scripts.
The following bat
script allows to automate the connection of Bluetooth devices.
Before using this script, you need to find out the Bluetooth type and name of your device:
BluetoothDevicePairing.exe discover
command that will print the required information.How to use the script:
C:\my\apps\BluetoothDevicePairing.exe unpair-by-name --name "MX Ergo" --type BluetoothLE --discovery-time 1
C:\my\apps\BluetoothDevicePairing.exe pair-by-name --name "MX Ergo" --type BluetoothLE --discovery-time 10
if %ErrorLevel% NEQ 0 (
pause
exit /b %errorlevel%
)
To pair a device by name, the utility starts by discovering all available devices and tries to find a device with the required name. After a device is found, its Mac address is used to request pairing. The command will fail if there are several devices with the same name.
If the command fails, it returns the value -1
. If it succeeds, it returns 0
.
Visual Studio 2022
to open the solution file and work with the codebuild.ps1
to build a release (to run this script, git.exe
should be in your PATH)