I have just downloaded the two .msi installers for 7zip (x86 and x64). Does anyone have a simple script I can use to detect the OS and launch the appropriate .msi file?

Answer Summary:
See my reply below
Cancel
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Community Chosen Answer

5

If anyone's curious, this is how I ended up doing it:

 

Set WshShell = WScript.CreateObject("WScript.Shell")
OSArchCheck = WshShell.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")

If OSArchCheck = "x86" Then
	WshShell.Run "msiexec.exe /qn /i install_x86.msi /norestart"
Else
	WshShell.Run "msiexec.exe /qn /i install_x64.msi /norestart"
End If
Answered 07/02/2012 by: nivek03
Senior White Belt

Please log in to comment

Answers

3

@nivek03

I started using autohotkey for all my scripts because things like this are not easily possible using bat/cmd scripts.  This is what I use to detect 32 bit on 64 bit architecture. (autohotkey scripting language)

IfExist, C:\Program Files (x86)\*
{   
    Run 64bit_App.msi
} else {
    Run 32bit_App.msi
}

Simple.

Answered 07/03/2012 by: aaronbaird1
White Belt

Please log in to comment
1
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto AMD64
if "%PROCESSOR_ARCHITEW6432%"=="AMD64" goto AMD64

if "%PROCESSOR_ARCHITECTURE%"=="x86" goto x86

:AMD64

msiexec /i your_x64.msi /q

exit

:x86

msiexec /i your_x86.msi /q

exit
Answered 07/02/2012 by: dugullett
Red Belt

  • This seems good in concept, but I am more looking for the OS architecture as I have machines with 64 bit processors running 32 bit XP. Any ideas?
Please log in to comment
1
Powershell and WMI:

$os=Get-WmiObject -Class Win32_OperatingSystem

 

if ($OS.OSArchitecture -eq "64-bit")
{
    Do something
}

 

Without WMI (not tested, but should work): 

if ($env:PROCESSOR_ARCHITECTURE -eq "AMD64")

{

    Do something

}

 

Answered 07/09/2012 by: Ifan
Second Degree Green Belt

Please log in to comment
0
Answered 07/02/2012 by: SMal.tmcc
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity