Jump to content

Script to Install IE9 on Vista and 7


Recommended Posts

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


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

Found the solution:

ver | findstr /il "5.1." > nul

if %errorlevel% equ 0 goto winxp

ver | findstr /il "6.0." > nul

if %errorlevel% equ 0 goto winvista

ver | findstr /il "6.1." > nul

if %errorlevel% equ 0 goto win7

The 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:

:win7

if defined ProgramFiles(x86) goto win7x64

Link to comment
Share on other sites

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 :EOF
IF %OS_% EQU VISTA GOTO VIE9
REM Place commands for Windows 7 install below here
IF 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
:VIE9
IF 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...