2

PROBLEM: microsoft Designer Bluetooth Mouse and Keyboard disconnect if idle for 10min

UNSUCCESSFUL:

--> probably to weird BT connection

WORKAROUND: setting my laptop on Airplane mode on and off resets the clock in my devices; so tried to use Task Scheduler to run a batch file that would turn this mode on and off if the computer has been idle for 5 minutes.

QUESTION: could not find a command line / batch / script to turn this mode on or off. Even better would be to turn only Bluetooth on and off. Anyone?

Thanks a million, lots of questions around on how to fix such disconnect issues, have done all they suggested but now focusing on tihs workaround.

6
  • If in "Device Manager > Bluetooth" you see the Bluetooth radio, right-click it and select Properties. If the Power Management tab exists, uncheck "Allow the computer to turn off this device to save power".
    – harrymc
    Feb 25, 2023 at 19:58
  • Thank you, did that but does not fix the problem. Also removed drivers, all what you read on forums, does not work. Spent 2h with microsoft support last night who ended up reinstalling WIndows 11 components but no change.
    – jmw
    Feb 25, 2023 at 20:03
  • Did you see the 4 options in this post?
    – harrymc
    Feb 25, 2023 at 20:10
  • Also see this post.
    – harrymc
    Feb 25, 2023 at 20:18
  • so disappointing. Was full of hope seeing fixes on HID and USB power management settings which I had not seen before. Removed that power management option for all of them and just tried the 10min idle test - did not fix it.
    – jmw
    Feb 25, 2023 at 20:35

1 Answer 1

1

Yes you can turn Bluetooth on/off via batch script.

devcon enable "your_bluetooth_device_instance_id"
devcon disable "your_bluetooth_device_instance_id"

Here's an example script that would turn it on/off. Just get Windows Task Scheduler to run it every 5 minutes when idle.

@echo off

REM Set the threshold of idle time (in seconds)
set IDLE_TIME=300

REM Set the device instance IDs of your Bluetooth devices
set MOUSE_ID=your_mouse_device_instance_id
set KEYBOARD_ID=your_keyboard_device_instance_id

REM Get the last input time (in ticks)
for /f "usebackq tokens=3 delims=: " %%i in (`quser ^| findstr /B /C:">>>"`) do set LAST_INPUT=%%i

REM Loop forever
:loop

REM Get the current input time (in ticks)
for /f "usebackq tokens=3 delims=: " %%i in (`quser ^| findstr /B /C:">>>"`) do set CURRENT_INPUT=%%i

REM Calculate the idle time (in seconds)
set /a IDLE_TIME_DIFF=%CURRENT_INPUT% - %LAST_INPUT%
if %IDLE_TIME_DIFF% geq %IDLE_TIME% (

    REM Turn off Bluetooth
    devcon disable %MOUSE_ID%
    devcon disable %KEYBOARD_ID%

    REM Wait for 5 seconds to make sure Bluetooth is turned off
    timeout /t 5 /nobreak > nul

    REM Turn on Bluetooth
    devcon enable %MOUSE_ID%
    devcon enable %KEYBOARD_ID%

    REM Reset the last input time
    for /f "usebackq tokens=3 delims=: " %%i in (`quser ^| findstr /B /C:">>>"`) do set LAST_INPUT=%%i
)

REM Wait for 1 second before checking the input time again
timeout /t 1 /nobreak > nul

goto loop
6
  • Thank you Anonymoose. I only have limited programming skills, so sorry for newbee questions: - Device ID looks like: HID\{00001812-00.....4FB}_DEV_VID&020..... Shall I use all of this in ""? - I added a devcon disable just after setting the ID to check whether it will disable the device. Running the script though tells me " 'devcon' isnot recognized as an internal or external command, executable program ...". I forgot to mention I am running on Windows 11 if this changes anything.
    – jmw
    Feb 25, 2023 at 22:13
  • 1
    You need to download it. See Devcon - Windows CMD - SS64.com
    – DavidPostill
    Feb 25, 2023 at 23:03
  • OK, did that, thank you for point me there. devcom seems not to work on the device I am trying to disconnect -- either my BT devices, or Bluetooth Device (Personal Area Network) which I found out is the one behind the activation BT button on Parameters and my ideal target. So instead I tried pnputil /disable-device which does disable the device. Surprisingly though "disabled", it remains "connected" and my BT devices keep working. I can see that switching the BT activation button in Parameters connects and disconnects the device, it does not disable it. Any idea how I can do that?
    – jmw
    Feb 26, 2023 at 9:38
  • 1
    @jmw Your approach is better. The reason RadioControlCmd can turn on/off your Bluetooth device while devcon cannot is that disabling the device using devcon disable does not necessarily turn off the Bluetooth radio. It only removes the driver, which makes the device unavailable to the system. However, the Bluetooth radio may still be powered on.
    – Anonymoose
    Feb 26, 2023 at 11:55
  • 1
    thank you so much for your support Anonymoose.
    – jmw
    Feb 26, 2023 at 20:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .