Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account



Photo

Script to Install IE9 on Vista and 7

- - - - -

  • Please log in to reply
3 replies to this topic

#1
piglovesrat15

piglovesrat15

    Newbie

  • Member
  • 30 posts
  • Joined 21-December 10
  • OS:none specified
  • Country: Country Flag
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.


How to remove advertisement from MSFN

#2
Tripredacus

Tripredacus

    K-Mart-ian Legend

  • Super Moderator
  • 9,907 posts
  • Joined 28-April 06
  • OS:Server 2012
  • Country: Country Flag

Donator

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.
MSFN RULES | GimageX HTA for PE 3-5 | lol probloms
msfn2_zpsc37c7153.jpg

#3
piglovesrat15

piglovesrat15

    Newbie

  • Member
  • 30 posts
  • Joined 21-December 10
  • OS:none specified
  • Country: Country Flag
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

#4
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,540 posts
  • Joined 13-October 04
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

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





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users