32-64 bit batch file

Langford

[H]ard|Gawd
Joined
Apr 5, 2006
Messages
1,339
I need just a little help, with something that seems like it should be easy.

I am creating a simple Windows command line batch file as part of an automated software installation, but I want the script to avoid installing if the script is run on one of the 64 bit versions of windows. Basically I am just looking for a way to detect 64 Windows from within a command line batch file. being able to distinguish between XP and Vista is not necessary, but would be really cool.

Preferably, the method would not have to involve packaging any additional executables, but if that is the only way, I am willing to consider the option. I considered trying to use some of the environmental variables, but I don't really trust that they would be consistent enough across different systems for this purpose, and there aren't very many that are relevant to this anyhow.

I was thinking along the lines of this:
Code:
obscurecommand.exe
if errorlevel 1 goto sixfourbit
Or maybe this:
Code:
if exist "%systemroot%\fileuniqueto64bitwindows.dll" goto sixfourbit
 

mikeblas

[H]ard|DCer of the Month - May 2006
Joined
Jun 26, 2004
Messages
12,776
Can you use the PROCESSOR_ARCHITECTURE value? For Win32 rigs, it is X86. Is it something different for your Win64 rig?

Code:
C:\public>set PRO
[b]PROCESSOR_ARCHITECTURE=x86[/b]
PROCESSOR_IDENTIFIER=x86 Family 6 Model 15 Stepping 7, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=0f07
ProgramFiles=C:\Program Files
PROMPT=$P$G
 

Langford

[H]ard|Gawd
Joined
Apr 5, 2006
Messages
1,339
Can you use the PROCESSOR_ARCHITECTURE value? For Win32 rigs, it is X86. Is it something different for your Win64 rig?

Code:
C:\public>set PRO
[b]PROCESSOR_ARCHITECTURE=x86[/b]
PROCESSOR_IDENTIFIER=x86 Family 6 Model 15 Stepping 7, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=0f07
ProgramFiles=C:\Program Files
PROMPT=$P$G

It may be. The trouble I have right now is I'm not near a 64-bit system to look at it, or I probably wouldn't be asking. It might come down to me picking a nearby system and formatting for experimental purposes, but I just don't have one to spare at the moment.
 

der_jackal

Limp Gawd
Joined
Aug 11, 2006
Messages
412
PROCESSOR_ARCHITECTURE=amd64

I don't have an intel EMT system around to see what it says, but...

Why couldn't you just do something like this?

IF "%PROCESSOR_ARCHITECTURE%"=="x86" (
REM Do whatever you need to here for x86 / 32 bit machines.
) ELSE (
goto SixFourBit
)

Unless you're supporting a wide range of other processors. :)
 

der_jackal

Limp Gawd
Joined
Aug 11, 2006
Messages
412
It can also be IA64 for Itanium systems.

All 5,000 of them that exist outside of MSFT? ;)

IF "%PROCESSOR_ARCHITECTURE%"=="x 86" (
REM Do whatever you need to here for x86 / 32 bit machines.
) ELSE IF "%PROCESSOR_ARCHITECTURE%"=="ia64" (
goto WhyDidYouBuyThat
) ELSE (
goto SixFourBit
)
 
Top