Writing a BATCH File IF EXIST not working

时间:2016-10-20 18:56:48

标签: batch-file

I'm writing a batch file to install some software, but first I need to know if the system is 32 bit or 64 bit, and then goto the appropriate install. My code so far looks like this:

IF EXIST C:\Program File(x86) (
GOTO 64bit_install 
) ELSE (
GOTO 32bit_install )

No matter what system I try to install on, it always goes to the 64 bit install. I've tested the script on both a 32 bit VM and 64 bit VM. When I swap the GOTO statements, it just goes to the first GOTO XXbit_install. It's ignoring the ELSE statement. Please help!

2 个答案:

答案 0 :(得分:0)

You need to enclose file names and paths that have spaces with double quotes. You also spelled the directory name incorrectly.

IF EXIST "C:\Program Files (x86)" (
GOTO 64bit_install 
) ELSE (
GOTO 32bit_install )

答案 1 :(得分:0)

I did find another answer that is working as well. I was searching for IF EXIST, when I should have been looking for checking OS with BATCH or something. Here is the solution that worked:

IF EXIST "%PROGRAMFILES(X86)%" (GOTO 64bit_Install) ELSE (GOTO 32bit_Install)
相关问题