I already did something similar so I can give you advice but the way you're doing it is a bit difficult. Let me explain.
My next mission is to build an array of "accepted OSes" and run a for loop which iterates of the array of "acceptedOSes" and compares it to the localOS variable we just created. If localOS matches any"acceptedOS" [sic] then the script continues else it ends the script.
The Batch language does not support true arrays since it's more of a basic interpreter than a real programming language. The way to do it in batch is to figure out what the environment is, what the valid choices are and then exiting the script if any invalid anythings are found in a very linear fashion.
This dynamic building of arrays in batch is sorta technically possible but enormously difficult to implement and use since they are not naively supported and kinda pointless to be honest. I did something similar, let me know if you want the code for it but the way I would write what you are trying to do atm is as follows:
1) Windows has Versions (Win XP, Vista, 8) which are internally just build numbers like 6.1.7601
or you could shorten it to 6.0; 6.1; 6.2; 6.3; 10.0 from: "wmic os get version /format:list" or diskpart with a for loop using the . as a delim
2) Architectures (x86, AMD64, ARM)
From the %processor_architecture%
3) and Editions (Ultimate, Home, Pro, Enterprise, Enterprise S, Basic)
from: wmic os get Caption /format:list
Comparing any of the above is easy but not if you combine them like "Microsoft Windows 7 Professional" since then you're comparing both a Version and an Edition at the same time. You can just build really long valid version lists and compare extremely linearly but it's more scalable to split them up and compare them independently.
I recommend figuring out what are all the valid choices and looking for patterns.
Are all Win7 Editions valid but only x86? Is Win Vista supported or Win 10, but not Win 8.1?
Then you can do something like this. This will only find x86 versions of certain windows versions valid.
::compare the Architecture first
if /i "%processor_architecture%" equ "x86" set architecture=x86
if /i "%processor_architecture%" equ "AMD64" set architecture=x64
if /i "%architecture%" equ "x86" set IsArchitectureValid=true
if /i "%IsArchitectureValid%" neq "true" (echo invalid OS Only 32-bit systems are supported
echo current OS architecture: %architecture%
::compare the Version next
for /f "tokens=1* delims== skip=2" %%i in ('wmic os get version /format:list') do (set rawWimOSVersion=%%j
for /f "delims=. tokens=1,2" %%i in ("%rawWimOSVersion%") do set rawWimOSVersion=%%i.%%j
if /i "%rawWimOSVersion%" equ "6.0" (set OSVersion=Vista)
if /i "%rawWimOSVersion%" equ "6.1" (set OSVersion=7)
if /i "%rawWimOSVersion%" equ "6.2" (set OSVersion=8)
if /i "%rawWimOSVersion%" equ "6.3" (set OSVersion=81)
if /i "%rawWimOSVersion%" equ "10.0" (set OSVersion=10)
if /i "%OSVersion%" equ "7" set IsVersionValid=true
if /i "%OSVersion%" equ "8" set IsVersionValid=true
if /i "%OSVersion%" equ "81" set IsVersionValid=true
if /i "%isOSValid%" neq "true" (echo invalid OS, Only 7 to Win 8.1 are supported
echo current OS version is Windows %OSVersion%
::valid OS code goes here
echo script done
Editions do not really matter as far as programs are usually concerned but if you want to compare them then filter out the 4th entry from the "wmic os get Caption /format:list" command.
for /f "tokens=1* delims== skip=2" %%i in ('wmic os get caption /format:list') do (set localOS=%%j
for /f "tokens=4" %%i in ("%localos%") do echo Edition is: %%i
And then it would be possible to figure out the valid editions.
::Non-WMIC way to get Windows Version (for WinPE without WMI packages)
diskpart /s nonexist.txt > temp.txt
for /f "tokens=4" %%i in ('find /n "version" temp.txt') do set rawVersion=%%i
for /f "tokens=1,2 delims=." %%i in ("%rawVersion%") do set rawVersion=%%i.%%j
if /i "%rawVersion%" equ "6.0" (set winVersionNumber=2.0
if /i "%rawVersion%" equ "6.1" (set winVersionNumber=3.x
if /i "%rawVersion%" equ "6.2" (set winVersionNumber=4.0
if /i "%rawVersion%" equ "6.3" (set winVersionNumber=5.x
if /i "%rawVersion%" equ "10.0" (set winVersionNumber=10.0