Vista 64-bit Batch File Variable Questions

ElectroGoofy

Distinguished
Aug 3, 2009
275
0
18,780
Hello, all

Ok, I have been working on a batch script to copy some files into a certain directory on a lot of computers. The one problem I am having is that most of the computers are 32-bit, but there are a few 64-bit OSs. What I am trying to do it set up a variable that is set to either Programfiles or Programfiles (x86), depending on whether it is 32 ot 64-bit. This way I would not have to keep updating two batch files, and would only need to worry about one of them.

The following is the script that I tried, but can't seem to make work, any suggestions?


IF %PROCESSOR_ARCHITECTURE%==x86 GOTO 32bit ELSE IF %PROCESSOR_ARCHITECTURE%==AMD64 GOTO 64bit

:32bit
SET ProgFiles=%ProgramFiles%
GOTO Continue

:64bit
SET ProgFiles=%ProgramFiles(x86)%
GOTO Continue

:Continue




For some reason when I run it on a 64bit and it fails, I go and look back at that line and it says:

IF AMD64==x86 GOTO 32bit ELSE IF AMD64==AMD64
SET ProgFiles=%ProgramFiles%




Thanks in advance!
 


This is true, a 64 bit CPU will have AMD64 in the string, but just because the CPU is capable of 64 bit instructions does not mean that you have a 64 bit OS on it.

To use an analogy (because I like to), it's like assuming that every minivan you see drive by has a family in it. Sure they "can" hold a large family, but maybe a single guy bought it for the space to hold his dogs or something. Every CPU now has 64 bit in it, bue many setups are still done using the 32 bit versions of the OS.
 


NOt sure that will work 100% of the time though --- For example I have a 32 bit VISTA system and since I installed a program for my neice to use called Timez Attack (a math learning program ) - the installer for it copied iself to the Program FIles (x86) folder (creating the folder even though the system is 32 bit!!) -- so any program checking using your method would think my system had a 64 bit OS and install improperly !! (and I'm sure there are other program installers that do the same which will cause you headaches and support calls if you use that method of checking.
 

TRENDING THREADS