Jump to content

Is there a test to determine 64bit or 32bit?


Aerospace

Recommended Posts

Hello, I am working on a manual Vista update script (well batch actually) and I'm looking to find if there is some sort of test as a command line, VB script or something of that nature to determine if the current installation of Vista is x64 or x86. Right now I have 2 separate batch files, one for each type (x64 and x86.) I would like to simplify it to one that could determine on its own which set of updates to use. I've had no luck searching the forum or Google. Does anyone know of any relatively painless way to do that or is what I want going to be a complex project?

Link to comment
Share on other sites


If it's a straight batch file then you could add the following to make a conditional jump if the installed OS is not 64-bit:

if "%programfiles(x86)%XXX"=="XXX" goto 32BIT

Follow this line with your 64-bit specific parts, and where the 32-bit part starts have the following label:

:32BIT

The following is a complete batch file which just echos to the screen which platform it believes is present, as an example:

@echo off

if "%programfiles(x86)%XXX"=="XXX" goto 32BIT

echo 64-bit Windows installed

goto END

:32BIT

echo 32-bit Windows installed

:END

Edit:

An alternative could be to check the environment variable PROCESSOR_ARCHITECTURE, e.g.

if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto 64BIT

(Yes, on Intel Core2 Duo CPUs this variable is still reported as AMD64.)

Link to comment
Share on other sites

Here is a VBS script that will report back if it either a x86 or x64

Save as Checkx86x64.vbs

Dim Col, Obj, strComputer, Wmi
strComputer = "."
Set Wmi = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set Col = Wmi.ExecQuery("SELECT * FROM Win32_Processor",,48)
For Each Obj in Col
'-> X86
If InStr(LCase(Obj.Caption),LCase("x86")) Then
'-> Place Your Code Below Here
Wscript.Echo "Caption: " & Obj.Caption
End If
'-> X64
If InStr(LCase(Obj.Caption),LCase("x64")) Then
'-> Place Your Code Below Here
Wscript.Echo "Caption: " & Obj.Caption
End If
Next

Link to comment
Share on other sites

Thanks guys! You've given me a lot to work with now. I'll play around with these and see what's going to work best for me.

@Mr Snrub: The Program Files x86 folder test is so simple, I don't know why I didn't think of it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...