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 like bluetooth.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:
![](../../I/static/images/76b608a3f24b49aac49836e240959b91f98bfecbde6b2957f231cb9a5ffecc09.png)
If the service is running, you'll see:
![](../../I/static/images/7a90aafdf6f0ba84d60f07f12906a68f04a84f234855c44293c0e7d16575e093.png)
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)
![](../../I/static/images/2aee7831f1d2dc7c67159881bab4ad42dc92f6ca69f9e83f0d102727c0f16695.png)
- Right click on the shortcut, click properties, then find the "Shortcut" tab at the top. Click "Advanced"
![](../../I/static/images/0a2f2f57b34a17ef703ea296bdb8e80927552c414fb7a4ee1af81c52005f8810.png)
- Select "Run as Administrator"
![](../../I/static/images/f7116f671b2493c4ca9c749b946bb03e772127fe9115a59c5aa2d7ce0bfc45ce.png)
- From now on, run the shortcut instead! All done.
1This does not work on Windows 8.1. – Ahmed – 2015-10-23T03:40:30.390
@Ahmed What about it doesn't work? AFAIK the service name is the same. What error do you get, in specific? – Insane – 2015-10-23T03:41:22.063
No error, just after i ran the .bat file as administrator, my bluetooth is still on and my bluetooth speaker is still connected to computer. – Ahmed – 2015-10-23T03:44:01.063
Add @pause at the end of the script to see the error, to prevent the .BAT from automatically closing. Paste the output. – Insane – 2015-10-23T03:45:27.830
The following services are dependent on the Bluetooth Support Service service. Stopping the Bluetooth Support Service service will also stop these services.
Bluetooth Handsfree Service
Do you want to continue this operation? (Y/N) [N]: y The Bluetooth Handsfree Service service is stopping. The Bluetooth Handsfree Service service was stopped successfully.
The Bluetooth Support Service service is stopping. The Bluetooth Support Service service was stopped successfully. – Ahmed – 2015-10-23T04:07:39.853
1I ran it again and it gave the appropriate turning "off" and turning "on" if run again. – Ahmed – 2015-10-23T04:09:38.350
Ah so it works now? Seems like you had to select yes for that initial. If it works as intended now I'll edit my answer with what you found. – Insane – 2015-10-23T04:10:27.320
1Well, it's not doing anything. My bluetooth is still connected and playing music. Nothing seems to be affected. – Ahmed – 2015-10-23T05:05:04.117
@Ahmed Has something to do with the Bluetooth Handsfree Service. Go to services, find the Bluetooth Handsfree Service and grab the actual service name and I'll amend the code to stop and start both services at once. I think that'll fix it. – Insane – 2015-10-23T05:06:51.377
"BthHFSrv" and "bthserv" – Ahmed – 2015-10-23T17:01:57.050