user3597409
user3597409

Reputation: 39

How to determine 32bit vs 64bit Windows at software installation time

I am trying to write a script that will install one of 6 different .MSI files depending on details of the system. I don't know how to tell the difference between a 32-bit and a 64-bit Windows installation, so that I can install the 64-bit .MSI on 64-bit systems and the 32-bit .MSI on 32-bit systems. The script is in Python, if that matters.

Upvotes: 1

Views: 2562

Answers (4)

Codename K
Codename K

Reputation: 744

The following registry entry will show you whether the system is 32bit or 64bit,

Key Path: HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0

Value Name: Platform ID

Value Type: REG_DWORD

For 32bit,

Value Data (in Hex.): 1

For 64bit,

Value Data (in Hex.): 2

Upvotes: 0

Bogdan Mitrache
Bogdan Mitrache

Reputation: 11013

You can also create an MSI or EXE wrapper that will install the package one by one. The tutorial I linked explains how to do this very easy with Advanced Installer, not scripting is required as you have GUI options to configure each installer, so it is much easy to maintain.

Advanced Installer allows you to select from a tree on which OS you want to run each package, so you can specify to run only on x64 or x86 machines, or on just a particular set of x64 or x86 machines. Install Conditions in Advanced Installer

You do need however a Professional license to the tool, but you can try it for 30 days, to see if it saves you enough time to make it worth the migration, as it should do.

Upvotes: 1

Fabricator
Fabricator

Reputation: 12782

Use this function:

import platform
platform.architecture()
# ('64bit', 'ELF')

or

import os
is64 = os.environ.get("PROCESSOR_ARCHITEW6432") == 'AMD64' or \
       os.environ["PROCESSOR_ARCHITECTURE"] != 'x86'

Upvotes: 1

Jakob Bowyer
Jakob Bowyer

Reputation: 34698

The best way is.

is_64bits = sys.maxsize > 2**32

Upvotes: 0

Related Questions