piglovesrat15 Posted March 21, 2011 Share Posted March 21, 2011 Hello! I'm trying to create a simple cmd script to install IE9 depends on user Windows version (Vista x86 & x64 and 7 x86 & x64). I tested on Windows 7 x86 and x64 fine using "if exist" for either x86 or x64 but I'm stuck on how to tell it to distinguise between Vista (SP1 and SP2) and 7 (Build 7600 and Build 7601 SP1). Anyone out there can give me some information? Thanks. Link to comment Share on other sites More sharing options...
Tripredacus Posted March 22, 2011 Share Posted March 22, 2011 You can get this information from WMI, specifically the Win32_OperatingSystem class, and the BuildNumber property. Not sure how to get that from a regular CMD file. I've done it with AutoIT and I've seen others use VBScript and other things too. Link to comment Share on other sites More sharing options...
piglovesrat15 Posted March 23, 2011 Author Share Posted March 23, 2011 Found the solution:ver | findstr /il "5.1." > nulif %errorlevel% equ 0 goto winxpver | findstr /il "6.0." > nulif %errorlevel% equ 0 goto winvistaver | findstr /il "6.1." > nulif %errorlevel% equ 0 goto win7The above will check for the version number and then goto depends on the OS. If it's XP then it gives an error. I also added a line to check wether it's a 64-bit or not and install IE9 accordingly. For example::win7if defined ProgramFiles(x86) goto win7x64 Link to comment Share on other sites More sharing options...
Yzöwl Posted March 23, 2011 Share Posted March 23, 2011 Unfortunately that is not a solution!That script is looking at the version of the command interpreter not of the Operating System, granted they are usually the same but not always.There is no upper/lower case difference with those characters therefore the /i switch is not required.A more robust batch file method may be this (untested):@ECHO OFF&SETLOCAL ENABLEEXTENSIONS(SET OS_=)FOR /F "TOKENS=*" %%# IN ('NET CONFIG WORK^|FIND /I " WINDOWS "') DO ( (ECHO=%%#|FINDSTR/I "VISTA 2008">NUL 2>&1)&&(SET OS_=VISTA) (ECHO=%%#|FIND /I " 7 ">NUL 2>&1)&&(SET OS_=WIN7))IF NOT DEFINED OS_ GOTO :EOFIF %OS_% EQU VISTA GOTO VIE9REM Place commands for Windows 7 install below hereIF DEFINED ProgramW6432 ( REM Place install command for Windows 7 x64 below here REM Place install command for Windows 7 x64 above here ) ELSE ( REM Place install command for Windows 7 x86 below here REM Place install command for Windows 7 x86 above here )GOTO :EOF:VIE9IF DEFINED ProgramW6432 ( REM Place install command for Vista or 2008 x64 below here REM Place install command for Vista or 2008 x64 above here ) ELSE ( REM Place install command for Vista or 2008 x86 below here REM Place install command for Vista or 2008 x86 above here )GOTO :EOF Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now