

We then load the assembly so that we can use the WindowsRuntimeSystemExtensions.AsTask method to convert WinRT-style tasks (which.

Before beginning in earnest, we make sure the Bluetooth Support Service is running and start it if not. The first three lines establish the parameters the script takes. To make that unnecessary, you can change the startup type of that service to automatic. Alas, the service cannot be started if the script is not running as administrator. \bluetooth.ps1 -BluetoothStatus OnĬaveat: If the Bluetooth Support Service is not running, the script attempts to start it because otherwise, WinRT will not see Bluetooth radios. To run it from a batch file: powershell -command.

Then you can run it from a PowerShell prompt like this. If you haven't already, follow the instructions in the Enabling Scripts section of the PowerShell tag wiki to enable the execution of scripts on your system. | Out-NullĪwait ($bluetooth.SetStateAsync($BluetoothStatus)) () | Out-Null If ((Get-Service bthserv).Status -eq 'Stopped') This is challenging because of the necessary interoperation with WinRT, but it is possible in pure PowerShell: Param ( I can't believe Microsoft would be so ignorant to not provide such a command… using explorer: ms-settings:bluetooth or explorer.exe %LocalAppData%\Packages\windows.immersivecontrolpanel_cw5n1h2txyewy\LocalState\Indexed\Settings\cs-CZ\AAA_ttingcontent-ms… opens the Bluetooth settings panel, but I still have to click on the toggle.NET: The most relevant page on MSDN doesn't say a word about turning the adapter on/off. using net as admin: net stop bthserv… doesn't actually turn off the radio (BT speaker continues playing music).using powershell as admin: Disable-NetAdapter "Bluetooth Network Connection 3" (which is translation of the name of my Bluetooth adapter)… it disables the PAN driver, but a Bluetooth speaker continues playing music….using devcon as admin: devcon disable USB\VID_8087&PID_07DC&REV_0001 (which is the HW ID of my Bluetooth adapter)… requires reboot to work….What I've tried (with music playing through a Bluetooth-connected speaker to really know the state of the radio): Such a simple task, one would say, and I haven't found a satisfiable solution.
