I figured out one solution but it does not touch “Airplane Mode.” Would love a better solution.
It involves using the net start
and net stop
(with /Y and admin) commands on the BthServ and WlanSvc. Martin, the asker of this question mentioned that using net stop bthserv... doesn't actually turn off the radio (Bluetooth speaker continues playing music)
-- but in my experience it works and does stop all connections / music etc. (tested on windows 11)
Just read the instructions:
:: Stops (or starts) the Bluetooth serivce (BthServ) and the Wifi service (WlanSvc).
:: Name this file "btOnOffBat.bat".
:: Run it as "btOnOffBat.bat -off" (for example as a shortcut or via cmd) (and set it to run as adminitrator), and Windows (and any devices) will no longer be connected.
:: Run it as "btOnOffBat.bat -on" (for example as a shortcut or via cmd), and Windows (and any devices) will automatically reconnect. (for example your wifi, and bluetooth mouse will reconnect)
:: You can also use this .bat in a Task Scheduler task on sleep (or wake) to stop the stupid Windows S3 "hybrid sleep" from keeping your radios on, draining battery, stealing your bt connections, or waking up due to radio connection events, while it is supposed to be sleeping!
:: More info on task scheduler and event codes:
:: Make sure you set the event to "Run with highest privileges".
:: For on Sleep event: Set task to run "On an event" trigger, with Log: System, Source: Power-Troubleshooter, Event ID 42.
:: For on Wake event: Set task to run "On an event" trigger, with Log: System, Source: Power-Troubleshooter, Event ID 1.
:: (The Action is "Start a program", with this .bat file as the target, and the -on or -off argument.)
:: (remember to also (un)tick any other relevant things like running on battery, run before login etc)
@echo off
if "%~1"=="-off" (
net stop bthserv /y
echo Bluetooth bthserv is now OFF.
net stop WlanSvc /y
echo Wifi WlanSvc is now OFF.
) else if "%~1"=="-on" (
net start bthserv /y
echo Bluetooth bthserv is now ON.
net start WlanSvc /y
echo Wifi WlanSvc is now ON.
) else (
echo please specify either -on or -off.
)
exit 0
[EDIT]
I caught in the Event Log:
- "The system is exiting Modern Standby" event, with Log Name: "System", Source: "Kernel-Power", Event ID: "507". And I didn't see a "1" event. So I'll tweak my task scheduler events and test some more.
- "The system is entering Modern Standby" with Name: "System", Source: "Kernel-Power", ID: "506". And I didn't see a "42".
[EDIT]
Bad news. This solution works perfectly, until you go to (s3) sleep. When you sleep, M$ makes sure all radio services are running and starts them if they aren't. I also tried to disable the task scheduler tasks, run this bat manually, go to sleep, and radios were on. Checked the event viewer, not sure we can do anything about it.
A solution that would work through sleep is to basically Disable the network adapter and (not sure if you can) Disable the bluetooth adapter, and then go to sleep... To automate this, you'd need to find the device IDs for the adapters.