[python-win32] How do I detect a 64 bit version of Windows?

Marc Hankin marc at marchankin.com
Mon Feb 20 03:28:34 CET 2012


Dear Gelonida:

The following is a vbscript that will return the info you want.  You might
want to run it in a python subprocess.



On Error Resume Next

' ------ SCRIPT CONFIGURATION ------
strComputer = "."   ' e.g. rallen-srv01
' ------ END CONFIGURATION ---------

set objWMIDateTime = CreateObject("WbemScripting.SWbemDateTime")

set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set colOS = objWMI.InstancesOf("Win32_OperatingSystem")
for each objOS in colOS
 strOs32OR64bit = objOS.OSArchitecture
sOSname = objOS.Caption
Next

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
WScript.Echo "Line 21:  strOs32OR64bit = objOS.OSArchitecture = " &
strOs32OR64bit

Hope that helps.

                                  Marc



On Sun, Feb 19, 2012 at 12:53 PM, Gelonida N <gelonida at gmail.com> wrote:

> On 02/19/2012 08:20 AM, Brian Curtin wrote:
> > On Sat, Feb 18, 2012 at 21:11, Gelonida N <gelonida at gmail.com> wrote:
> >> On 02/18/2012 09:07 PM, Brian Curtin wrote:
> >>> On Sat, Feb 18, 2012 at 13:22, Gremlin <gremlin at armarize.com> wrote:
> >>>
> >>> import platform
> >>> platform.machine()
> >>>
> >>> That will return "AMD64" on 64 bit. I don't have a 32-bit machine
> >>> available but I believe it returns "x86".
> >> This suggestion will not work for the OP.
> >>
> >> It will tell you the platform, for which python was compiled and not the
> >> real platform of the machine you're running on.
> >>
> >> If you installed a 32 bit version of python on a 64 bit machine You will
> >> get 'x86', which would be the wrong answer considering the OP's
> >> requirements.
> >
> > This is false.
> >
> > platform.machine() is about the the computer itself - I fixed it in
> > 2.6 to function properly, as it used to operate similar to
> > platform.architecture() due to looking in the wrong place.
> > platform.architecture() is about how Python was compiled.
>
> Hmmm.
>  I use python 2.6.4 on a 64 bit machine and get 'x86' as result.
> perhaps it's only fixed in the newer 2.6 releases?
>
>
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>



-- 

 ********************************************************************

The Law Offices of Marc B. Hankin, Inc.

Post Office Box 3668, Beverly Hills, California  90212 (Not for
mail:509S.BeverlyDr.)

Tel: (310) 552-3005     Fax: (310) 382-2416

Email: marc at marchankin.com    Website:  www.marchankin.com

     This e-mail message is generated from the law firm of the Law Offices
of Marc B. Hankin, Inc., and may contain information that is confidential
and may be privileged as an attorney/client communication or as attorney
work product.  The information is intended to be disclosed solely to the
addressee(s).

     If you are not the intended recipient, any disclosure, copying,
distribution or use of the contents of this e-mail information is
prohibited.  If you have received this e-mail in error, please notify the
sender by return e-mail and delete it from your computer system.

********************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20120219/0d5bfc92/attachment-0001.html>


More information about the python-win32 mailing list