I need to find which windows 10
is installed via a batch file.
If it is between 1607
and RS4 build
I will install x.exe
if it is rs4
or higher I will not install x.exe
.
So I need an if/else
statement to make it work?
threshold 1 1507 10240
threshold 2 1511 10586
redstone 1 1607 14393
redstone 2 1703 15063
redstone 3 1709 16299
redstone 4 1803 17134
redstone 5 1809 17650
Maybe to check if it is between 14393
to 16299
or I could just check if it is 1607
or anything else etc.
Here's one possible way, using WMIC
:
@Echo Off
Set "VN="
For /F "EOL=V Tokens=*" %%A In (
'WMIC OS Where "Version<'4'" Get Version 2^>Nul'
) Do For /F "Tokens=3 Delims=." %%B In ("%%A") Do Set "VN=%%B"
If Not Defined VN Exit /B
If %VN% GEq 11082 If %VN% LEq 16299 Set "VN="
If Defined VN Exit /B
Rem your install code goes here.
Notes:
There were three preview releases of Threshold 1
which are not covered by my WMIC
code: 6.4.9841
, 6.4.9860
and 6.4.9879
The first release covered by my first 6
lines is the preview version of Threshold 1
released on January 23 2015, 10.0.9926
; every other release since should work up to that point!
The following releases are covered by my answer:
10.0.11082
December 16 2015 up to 10.0.14390
July 15 201610.0.14393
From July 18 201610.0.14901
August 11 2016 up to 10.0.15061
March 17 201710.0.15063
From March 20 201710.0.16170
April 7 2017 up to 10.0.16296
September 22 201710.0.16299
From September 26 2017Edit
This code is added for the purposes of an additional OP requirement in the comment section.
@Echo Off
Set "VN="
For /F "EOL=V Tokens=*" %%A In (
'WMIC OS Where "Version<'4'" Get Version 2^>Nul'
) Do For /F "Tokens=3 Delims=." %%B In ("%%A") Do Set "VN=%%B"
If Not Defined VN Exit /B
If %VN% GEq 11082 If %VN% LEq 16299 Set "VN="
If Defined VN GoTo SkipInstall
Rem your install code goes here.
Exit /B
:SkipInstall
Rem your code for Threshold or Redstone 4 goes here.