Skip to content

Instantly share code, notes, and snippets.

@FabulousCupcake
Created August 27, 2021 18:49
Show Gist options
  • Save FabulousCupcake/3cc04eb656f99045e3e7e1c79fcb1fa9 to your computer and use it in GitHub Desktop.
Save FabulousCupcake/3cc04eb656f99045e3e7e1c79fcb1fa9 to your computer and use it in GitHub Desktop.
Actually Disabling Bluetooth Autoconnect on Startup in Windows

Actually Disabling Bluetooth Autoconnect on Startup in Windows

Situation

I use multiple devices with my bluetooth earphone connected to my mac machine, phone, or tablet.
When I boot my windows machine, it automatically connects to and snatches my bluetooth earphone. This is very annoying.

Results from google on ways to disable this are unhelpful:

  • Unpair the device (???)
  • Disable bluetooth support system service via services.msc
  • Disable the device via Device Manager

Solution

To fix this, I disable Microsoft Bluetooth Enumerator device on shutdown, so on the following startup it will not attempt to automatically connect to the paired bluetooth devices.
To reenable it, I made a desktop shortcut runs a script to reenable the device, restoring Bluetooth to the normal state.

Disabling Bluetooth with Powershell

This was easier than I expected.
I found a one-liner command on reddit that finds the Microsoft Bluetooth Enumerator entity and enables/disables it.

(GWMI Win32_PNPEntity -Filter "caption like '%bluetooth enumerator%'").Enable()
(GWMI Win32_PNPEntity -Filter "caption like '%bluetooth enumerator%'").Disable()

Re-enabling bluetooth with Desktop Shortcut

Once I have bluetooth disabled on startup, I want to be able to reenable it easily at any point after.
I created a shortcut that executes the command above, saved in a .ps1 file somewhere.

The script needs to be executed as administrator, and simply double clicking the .ps1 file does not do anything, so create a shortcut and modify it to run the script with powershell:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -file "D:\enable-bt.ps1"

Then set it to be run as administrator in the advanced properties.

Running the script on shutdown

Apparently Windows has this neat thing called Task Scheduler.
I initially tried to configure the disabler script to be run on startup, but it is not done early enough.
On boot, it snatches the bluetooth earphone and then the disabler runs.

Fortunately there is a super obscure event that triggers precisely right before shutdown, explained in stackexchange.
With this, on subsequent boot bluetooth is disabled and does not auto-connect.
To reenable it at any point after the startup, I can simply doubleclick the enabler script shortcut on my desktop.

@jmuellers
Copy link

Thank you. I am, literally, really, tearing up because there finally seems to be a practical solution to handle this nonsense. Glad I stumbled upon your solution.
Best, J

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment