OS detection script

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?

0 Comments   [ + ] Show comments

Answers (5)

Answer Summary:
See my reply below
Posted by: nivek03 11 years ago
Senior White Belt

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"
	WshShell.Run "msiexec.exe /qn /i install_x64.msi /norestart"
End If
Posted by: aaronbaird1 11 years ago
White Belt


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


Posted by: dugullett 11 years ago
Red Belt
if "%PROCESSOR_ARCHITEW6432%"=="AMD64" goto AMD64

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


msiexec /i your_x64.msi /q



msiexec /i your_x86.msi /q


  • 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? - nivek03 11 years ago
Posted by: Ifan 11 years ago
Second Degree Green Belt
Powershell and WMI:

$os=Get-WmiObject -Class Win32_OperatingSystem


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


Without WMI (not tested, but should work): 



    Do something



This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ