How do I find out if a DOS batch script runs on Win 7 oder Win 10?
Thank you
Peter
How to find out if a DOS batch script runs on Win 7 oder Win 10?
Moderator: DosItHelp
Re: How to find out if a DOS batch script runs on Win 7 oder Win 10?
You may process the output of the VER command.
The code multiplies the major version by 100 and adds the minor version. Thus, Win7 results in 601 while Win10 resultts in 1000.
Please see the List of Windows versions (column "Release version").
I assembled major and minor version as integer value in order to be able to easily compare it. E.g.
Steffen
Code: Select all
@echo off &setlocal
for /f "tokens=2 delims=[" %%i in ('ver') do for /f "tokens=2,3 delims=. " %%j in ("%%i") do set /a "winver=%%j * 100 + %%k"
echo "%winver%"
pause
The code multiplies the major version by 100 and adds the minor version. Thus, Win7 results in 601 while Win10 resultts in 1000.
Please see the List of Windows versions (column "Release version").
I assembled major and minor version as integer value in order to be able to easily compare it. E.g.
Code: Select all
if %winver% lss 1000 echo Previous to Win10.
Steffen
-
- Posts: 118
- Joined: 02 Apr 2017 06:11
Re: How to find out if a DOS batch script runs on Win 7 oder Win 10?
You can download the OS function from my website. Also be sure to read the article to find out how to use it.
Link :http://www.thebateam.org/2017/02/detect-current-operating-system-via-cmd.html#more
Link :http://www.thebateam.org/2017/02/detect-current-operating-system-via-cmd.html#more