Ressourcen für IT-Professionals > Forenhomepage > Windows HPC Server Deployment, Management, and Administration > How to determine whether an Windows OS is 64 bit or not from Registry Editor
Stellen Sie eine FrageStellen Sie eine Frage
 

BeantwortetHow to determine whether an Windows OS is 64 bit or not from Registry Editor

  • Freitag, 8. Februar 2008 12:16VenuGopal545 TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     

     

    Hi ,

     

    I need to run a batch file to check whether an operating system is 32 bit or 64 bit .This need to be checked in registry only .I am able to check for 32 bit OS However I never checked for 64 bit OS .So can anyone pls guide me how to know whether the OS is 64 bit or not ?

     

    We need to retrieve from Registry but not basing on the Hardware or the Processor Architecture .Is there any dword value please send me the response

     

    Thanx a lot folks............!

     

Antworten

  • Mittwoch, 9. April 2008 21:54Jarred Clore TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     Beantwortet

     You can do an IsWow64Process API call to see:

     

    typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);

    BOOL IsWow64()
    {

        BOOL bIsWow64 = FALSE; // assume 32 bit
     
        // can't call IsWow64Process on x32, so first look up the entry point in kernel32
        LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle ("kernel32"),"IsWow64Process");
     // if we have an entry point for IsWow64Process, we can call it
        if (NULL != fnIsWow64Process)
        {
            if (!fnIsWow64Process(GetCurrentProcess(),&bIsWow64))
            {
                // handle error
            }
        }
        return bIsWow64;
    }

     

Alle Antworten

  • Freitag, 8. Februar 2008 19:11Ryan WaiteMSFTTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     Vorgeschlagene Antwort

    I'm not sure how to do this from the registry but while researching for another post I figured out how to do this by querying WMI from PowerShell. This might work nicely for you if you're writing a script. The PowerShell script is:

     

        Get-WmiObject -class "Win32_Processor" -property "AddressWidth"

     

    If the AddressWidth is "32" then you're on a 32-bit operating system. If the AddressWidth is "64" then you're on a 64-bit operating system.

     

    A similar VB Script implementation is posted at: http://www.msfn.org/board/lofiversion/index.php/t90278.html.

     

    Ryan Waite

    • Als Antwort vorgeschlagenwelemon Donnerstag, 14. Mai 2009 06:46
    •  
  • Donnerstag, 3. April 2008 01:37progman32 TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     

    In the Windows (XP) registry look for :

    \HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion

    Look at CurrentBuildNumber = "####"

    We determine OS type usually by build number (i.e. XP 32-bit = 2600, XP 64-bit 3790)
  • Mittwoch, 9. April 2008 21:54Jarred Clore TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     Beantwortet

     You can do an IsWow64Process API call to see:

     

    typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);

    BOOL IsWow64()
    {

        BOOL bIsWow64 = FALSE; // assume 32 bit
     
        // can't call IsWow64Process on x32, so first look up the entry point in kernel32
        LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle ("kernel32"),"IsWow64Process");
     // if we have an entry point for IsWow64Process, we can call it
        if (NULL != fnIsWow64Process)
        {
            if (!fnIsWow64Process(GetCurrentProcess(),&bIsWow64))
            {
                // handle error
            }
        }
        return bIsWow64;
    }

     

  • Donnerstag, 10. April 2008 05:20JByy4u TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     

    Caution:  The below only shows whether or not your system is capable of running an x64 OS but that doesn't mean you're running x64.

     

    Get-WmiObject -class "Win32_Processor" -property "AddressWidth"

     

    If no one has a better solution to determine the running os as being x64 then I'm tempted to just look and see if the c:\program files (x86) folder exists and if so assume it's 64-bit.  Or maybe just parse the boot.ini. 

     

    JB

  • Mittwoch, 16. April 2008 07:10carter_chenMSFTTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     

    You can also do this in PowerShell:

    $envStick out tongueROCESSOR_ARCHITECTURE

     

    Christina

  • Donnerstag, 14. Mai 2009 06:46welemon TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     
    Really? In MSDN, it is described as:
    AddressWidth
    Data type: uint16
    Access type: Read-only

    On a 32-bit operating system, the value is 32 and on a 64-bit operating system it is 64. This property is inherited from CIM_Processor .

    and I tested with XP64 Vista32 XP32.  It shows the info of OS, not the CPU.