How can I toggle Bluetooth on and off via a shortcut or script in Windows 8.1?
Solution 1:
Yes, it can be done. I'm not sure if this is the easiest way, but it works
Creating a batch file
- Create a new
.bat
file and call it something likebluetooth.bat
- Inside the file, paste the following script
The script checks if the Bluetooth Support Service (bthserv) is running.
If running, it stops the service. If stopped, it starts the service.
@echo off
for /F "tokens=3 delims=: " %%H in ('sc query "bthserv" ^| findstr "STATE"') do (
if /I "%%H" NEQ "RUNNING" (
net start "bthserv"
) else if /I "%%H" NEQ "STOPPED" (
net stop "bthserv"
)
)
- Save the .bat and then run it as an Administrator
Execution
If the service is stopped, you'll see:
If the service is running, you'll see:
If you want to stop the window from automatically closing, add a new line with @pause
to the bottom of your script. Then you'll be prompted with Press any key to continue . . .
.
Edit from comments:
The first time you use the batch file, add @pause
to the bottom of the script and select y
for any prompts that appear. Then test it out once more to make sure it's working as intended. If it is, you can remove @pause
.
Always run as Administrator
If you want, which I assume you will, for the .bat
to always run as Admin, do the following:
- Right click on your
bluetooth.bat
and click "Send to" -> "Desktop (Create Shortcut)
- Right click on the shortcut, click properties, then find the "Shortcut" tab at the top. Click "Advanced"
- Select "Run as Administrator"
- From now on, run the shortcut instead! All done.