@Echo Off

Call :IsAdmin
CD /D %~dp0\

Set tApp=btVersion_x64.exe
If /i "%processor_architecture%"=="x86" Set tApp=btVersion.exe
If "%tApp%"=="" Set tApp=btVersion.exe

REM ~ %tApp% /P >%~dp0\BtOutput.txt
REM ~ %tApp% /P /U >%~dp0\BtOutput.txt

Call :Query %tApp% /V
REM ~ Call :Query %tApp% "/V /U"

If "%tRESULT%"=="1.0" (
	Echo Bluetooth 1.0b

) Else If "%tRESULT%"=="1.1" (
	Echo Bluetooth 1.1

) Else If "%tRESULT%"=="1.2" (
	Echo Bluetooth 1.2

) Else If "%tRESULT%"=="2.0" (
	Echo Bluetooth 2.0 + EDR

) Else If "%tRESULT%"=="2.1" (
	Echo Bluetooth 2.1 + EDR

) Else If "%tRESULT%"=="3.0" (
	Echo Bluetooth 3.0 + HS

) Else If "%tRESULT%"=="4.0" (
	Echo Bluetooth 4.0

) Else If "%tRESULT%"=="4.1" (
	Echo Bluetooth 4.1

) Else If "%tRESULT%"=="4.2" (
	Echo Bluetooth 4.2

) Else If "%tRESULT%"=="5.0" (
	Echo Bluetooth 5.0

) Else If "%tRESULT%"=="5.1" (
	Echo Bluetooth 5.1

) Else If "%tRESULT%"=="5.2" (
	Echo Bluetooth 5.2

) Else If "%tRESULT%"=="5.3" (
	Echo Bluetooth 5.3

) Else If "%tRESULT%"=="5.4" (
	Echo Bluetooth 5.4

) Else If "%tRESULT%"=="6.0" (
	Echo Bluetooth 6.0

) Else If "%tRESULT%"=="6.1" (
	Echo Bluetooth 6.1

) Else If "%tRESULT%"=="6.2" (
	Echo Bluetooth 6.2

) Else If "%tRESULT%"=="?.?" (
    Echo Bluetooth version not found!
) Else (
	Echo %tRESULT%
)

Pause & Exit


:Query
FOR /F "tokens=*" %%A in ('"%~1" %~2') do set tRESULT=%%A
Cls
goto:eof

:IsAdmin
Reg.exe query "HKU\S-1-5-19\Environment"
If Not %ERRORLEVEL% EQU 0 (
 Cls & Echo You must have administrator rights to continue ...
 Pause & Exit
)
Cls
goto:eof