windowsbatch-filecmdoperating-systemdetect

Windows OS compatibility for batch file needed


I want to make a Batch file program, that can is compatible with Windows 10 and later. Not with older Windows systems.

Pseudocode:

if Win10+ then
[insert continued code here]
else
echo We're sorry, but the program you are trying to run isn't compatible with your Windows OS version.
echo Minimal requirement: Windows 10 (or later)

Please comment with the code if you have it.

I tried:

if "%version%" == "10.0" [continue the code]
else echo Not compatible

Solution

  • Perhaps your could use 's help:

    @%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile "If ($([System.Environment]::OSVersion.Version.Major) -GE '10') { Exit 0 } Else { Exit 1 }"
    @If ErrorLevel 1 Exit /B
    @Rem Your Win10+ code goes here.