Created
January 14, 2017 03:10
-
-
Save danmaq/acca4003fea32e2f48e291bdc241fdca to your computer and use it in GitHub Desktop.
This Windows batch file verifies that the OS version is Windows 7 or later. If arguments exists, run it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
rem USAGE: exec_more_win7 [command: run on Windows7-10] [args for command] | |
rem ERRORLEVEL: 0: >= Win7, 1: < Win7 | |
rem EXAMPLE 1: call exec_more_win7 | |
rem EXAMPLE 2: exec_more_win7 msiexec /i installer4win7.msi /qn | |
rem Windows Vista (NT 6.0) | |
ver | find "Version 6.0" > nul | |
if not errorlevel 1 goto VISTA | |
rem Windows 7, 8 or 8.1 (NT 6.x) | |
ver | find "Version 6." > nul | |
if not errorlevel 1 goto MORE_7 | |
rem Windows 10 (NT 10) | |
ver | find "Version 10" > nul | |
if not errorlevel 1 goto MORE_10 | |
goto LESS_XP | |
rem OS >= Windows 7 | |
:MORE_7 | |
:MORE_10 | |
%* | |
exit /b 0 | |
rem OS < Windows 7 | |
:VISTA | |
:LESS_XP | |
echo FAILED: "%1" works only on Windows 7 and later versions. | |
exit /b 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment