Welcome!

By registering with us, you'll be able to discuss, share and exchange private messages with other members of our community.

SignUp Now!

minor difference, cmd vs tcc

May
61
0
@echo off
::

FOR /F "usebackq tokens=3" %%i IN (`REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CurrentBuild 2^>nul`) DO SET /A "CurrentBuild=%%i"

echo CurrentBuild from registry is %CurrentBuild%
IF %CurrentBuild% GEQ 22000 (
echo yes, we are windows 11 based on CurrentBuild
)


============================

This works in cmd and TCC, but gives a spurious error or warning in TCC:
============================

d:\batch>winver2.bat
TCC: D:\batch\winver2.bat [4] No expression ""
CurrentBuild from registry is 22621
yes, we are windows 11 based on CurrentBuild

d:\batch>cmd /c winver2.bat
CurrentBuild from registry is 22621
yes, we are windows 11 based on CurrentBuild

===========================
What would I need to change to make it work without warnings in both CMD and TCC ?
 
I didn't find a simple answer, but the following workaround will suffice:
=====================================
@echo off
::

SET "usebackquotes=usebackq"
IF 01 == 1 (
SET "usebackquotes= "
)
FOR /F "%usebackquotes% tokens=3" %%i IN (`REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CurrentBuild 2^>nul`) DO SET /A "CurrentBuild=%%i"

echo CurrentBuild from registry is %CurrentBuild%
IF %CurrentBuild% GEQ 22000 (
echo yes, we are windows 11 based on CurrentBuild
)
 
Back
Top