What's new

Turn off bluetooth from command line


New Member
I'd like to be able to turn bluetooth off and on programatically, using the command line or a non-gui program. Something that turns airplane-mode off and on programatically would be fine as well. A lot of googling has shown little joy, but much of that googling shows older information.

On my Pro 3, the Windows Device Manager shows seven Bluetooth devices: "Bluetooth Mouse M557" (a Logitech mouse), "Device Identification Service", "Microsoft Bluetooth Enumerator", "Microsoft Bluetooth LE Enumerator", "Service Discovery Service", "Surface Pen", and "Marvell AVASTAR Bluetooth Radio Adapter". I know that if I could simply disable and reenable the Marvell AVASTAR Bluetooth Radio Adapter I would achieve my objective. The problem is that the Device Manager right-mouse-button context menu for that device does not allow enablement or disablement (just uninstall), and so devcon cannot enable and disable the device. And disabling all of the devices that do allow disablement (including the mouse) does not in fact result in the mouse not operating the computer. (Only the radio and the Microsoft Bluetooth Enumerator lack the enable-disable context menu item.)

All I am trying to achieve is to have my mouse not wake the computer up during connected standby when I accidently jostle it on my desktop. When I stop working on the computer for a while, the screen turns off and the machine goes into connected standby. I'd like it to stay there until I touch the power button or a key on the keyboard, and not wake up when I bump the mouse doing paperwork. (Yes, the mouse has a physical button to turn it on or off. My desktop computer does not reqire me to flip a button on the mouse to have it not wake up the computer from sleep. I'd just like the same convenience with the Surface.)

Anyone got a pointer? An API? A script (but not a gui-mode keyboard-simulator script)? Or a different way to get my mouse to sleep while the screen is off? Or certain knowledge that this cannot be done? (I have not yet tried deleting the mouse entirely when the screen goes dark and doing a refresh when it lights back up as this sounds extreme.)


Active Member
Neat problem. I learned a lot trying to figure this one out just now. Sorry this is such a hassle for you btw. Its frustrating when this stuff just doesn't work the way you want. This problem isn't really specific to Surface, so you might have better luck on MSDN or answers.microsoft.com. But hopefully I can help.

I would try this approach first:
- In device manager, right-click on any attached device including the mouse and goto the "power management" tab if available
- Un-check "allow this device to wake the computer"
- save and reboot

You may need to do this for multiple devices in the chain. (view - devices by connection)

If that doesn't work, try this 3rd-party tool:
You need the "for 8.1 update" version. Just use task scheduler to run this when entering/exiting CS. This tool might stop working with updates at any time because the APIs backing this are not fully documented and the method used is against best-practices as far as I know. But if it works, it works.

For task scheduler, you'll probably want to trigger on an event related to "Kernel power" and event ID 42 (entering sleep) and event ID 131 (resume)
BTW I didn't *know* any of this, I just opened Event viewer and saw what was there when I slept my machine and resumed. If those eventIDs don't work, you'll have to sift through the logs yourself (painfully slow) to determine which events are being triggered. It might vary depending on which power profile you have setup.

If you want to program this yourself, these resources might help:

Some device drivers just don't support the "disable" function, especially those classified as "system devices". Does the mouse driver under "mices and pointing devices" support that function? If you're using a generic "PS/2 compatible" driver, try an alternate driver.
Last edited:


New Member
This is a status update to report that I have found a so-far accptable solution. (The third-party tool mentioned above is not what I was after because it is a GUI-mode keyboard simulator script.)

First, I finally discovered that if I disable one particular one of the three "HID-compliant mouse" items shown by Windows Device Manager (one that in passing does not have a power tab in its properties), then the bluetooth mouse would not in fact wake up the computer even though bluetooth itself remained fully enabled. So the problem now became simply to disable and reenable this particular mouse.

So, second, I wrote a script in AutoHotkey to run in the background. The script calls the Windows API RegisterSuspendResumeNotification and thereafter receives suspend and resume messages when the system goes into and leaves connected standby. PBT_APMSUSPEND and PBT_APMRESUMEAUTOMATIC are the ones I look for. When one of these comes by, I use devcon.exe to disable or enable the mouse as appropriate. (Of course all of usual fiddling to deal with elevated states and bypass UAC prompts must be taken care of by any of the standard methods for making background stuff run elevated.)

Finally, I added a task in the task scheduler that also calls devcon.exe to enable the mouse and trigger that task on system startup, user logon, and workstation unlock just in case the machine crashes or my script fails while I have the mouse disabled.

Members online