Sign in with
Sign up | Sign in
Your question

Vista 64-bit Batch File Variable Questions

Last response: in Windows Vista
Share
February 7, 2011 7:30:37 PM

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!
February 7, 2011 8:24:17 PM

Um.. that's because the processor architecure is not the type of Windows that's installed. Processor <> Windows version.

Use IF EXIST and check for the (x86) directory, set the OS type based on that.

http://support.microsoft.com/kb/65994
m
0
l
February 7, 2011 9:43:08 PM

Ah, ok.... it just seemed that on all the 64-bit comps it was AMD64, but for the rest it was just x86.

I'll try that once I get back to work, thanks :) 
m
0
l
Related resources
February 8, 2011 12:49:20 PM

ElectroGoofy said:
Ah, ok.... it just seemed that on all the 64-bit comps it was AMD64, but for the rest it was just x86.

I'll try that once I get back to work, thanks :) 


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.
m
0
l
February 8, 2011 12:58:59 PM

hang-the-9 said:
Um.. that's because the processor architecure is not the type of Windows that's installed. Processor <> Windows version.

Use IF EXIST and check for the (x86) directory, set the OS type based on that.

http://support.microsoft.com/kb/65994


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.
m
0
l
!