Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for bluetoothstatus.bat

(view source code of bluetoothstatus.bat as plain text)

  1. @ECHO OFF
  2. IF NOT "%~1"=="" GOTO Syntax
  3. DEVCON help >NUL 2>&1
  4. IF ERRORLEVEL 1 (
  5. 	ECHO.
  6. 	ECHO ←[0;31mERROR:←[0m DEVCON not found
  7. 	GOTO Syntax
  8. )
  9. SETLOCAL
  10. FOR /F %%A IN ('devcon.exe findall ^=Bluetooth @BTH*') DO SET CountAll=%%A
  11. FOR /F %%A IN ('devcon.exe find    ^=Bluetooth @BTH*') DO SET CountAct=%%A
  12. IF %CountAll% GTR 0 IF %CountAll% EQU %CountAct% (
  13. 	ECHO Bluetooth Enabled
  14. 	SET RC=0
  15. ) ELSE (
  16. 	ECHO Bluetooth Disabled
  17. 	SET RC=1
  18. )
  19. ENDLOCAL & EXIT /B %RC%
  20. GOTO:EOF
  21.  
  22.  
  23. :Syntax
  24. ECHO.
  25. ECHO BluetoothStatus.bat,  Version 1.00
  26. ECHO Use DEVCON to check if Bluetooth is enabled
  27. ECHO.
  28. ECHO Usage:  ←[0;1mBluetoothStatus.bat←[0m
  29. ECHO.
  30. ECHO Notes:  This batch file requires DEVCON, see
  31. ECHO         ←[0;1;30mhttps://www.robvanderwoude.com/devcon.php←[0m
  32. ECHO         Return code ("ErrorLevel") 0 if Bluetooth is
  33. ECHO         enabled, 1 if not, or -1 in case of errors.
  34. ECHO.
  35. ECHO Written by Rob van der Woude
  36. ECHO https://www.robvanderwoude.com
  37. EXIT /B -1

page last modified: 2024-04-16; loaded in 0.0074 seconds