Batch file to install multiple programs

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
lob
Posts: 5
Joined: 12 Jan 2011 15:29

Batch file to install multiple programs

#1 Post by lob » 12 Jan 2011 15:39

Hi all...I am VERY new to creating batch files and I'm having a bit of an issue here.

I want to create a batch file that will install multiple programs from a flash drive. Easy enough.

My dilemma is that these programs will need to be installed on both 32 bit and 64 bit machines, with different version for each platform.

The first dilemma is installing JRE. Java releases two versions of JRE, one for 32 bit and one for 64 bit. How can I specify in the batch file to ignore errors?

My code looks like this so far:

ECHO.
ECHO Installing Java Runtime Environment
ECHO Please wait...

start /wait %MYDRIVE%\Programs\Java32.exe /s
start /wait %MYDRIVE%\Programs\Java64.exe /s

What I have found is that on 64 bit machines both files will install with no error. On 32 bit machines, as soon as it gets to the 64 bit install, I get an error message. How can I avoid that error message? I dont want for the people installing the software to see any error.

The second question this:

Once Java is installed, the second program is installed. This program has only one installer for both 64 and 32 bit. No problem there. The issue is that I want to be able to automatically start the program once the install is complete. The problem is that depending on if you have 64 bit or 32, the directory the program is installed in changes. My code looks like this:

start /d "C:\Program Files\GSR\LOB" AFS.exe
start /d "C:\Program Files (x86)\GSR\LOB" AFS.exe

Obviously, everyone will get an error message with this one when it tries to open a location that doesnt exist. Is it possible to ignore that error message?

Many, many thanks in advance!!!

ChickenSoup
Posts: 79
Joined: 13 Dec 2010 10:32

Re: Batch file to install multiple programs

#2 Post by ChickenSoup » 12 Jan 2011 16:16

Just set it to check for 32 and 64 bit systems in the start:
(variable %ProgramFiles(x86)% does not exist on 32-bit windows)

Code: Select all

IF NOT "%ProgramFiles(x86)%"=="" (
echo.This is a 64-bit computer... Using 64-bit installers.
start /wait %MYDRIVE%\Programs\Java64.exe /s
start /d "C:\Program Files (x86)\GSR\LOB" AFS.exe
) else (
echo.This is a 32-bit computer... Using 32-bit installers.
start /wait %MYDRIVE%\Programs\Java32.exe /s
start /d "C:\Program Files\GSR\LOB" AFS.exe
)

lob
Posts: 5
Joined: 12 Jan 2011 15:29

Re: Batch file to install multiple programs

#3 Post by lob » 12 Jan 2011 19:15

This is exactly what I spent hours on google searching for. I'm so glad I found this forum. Thanks you so much...it works perfectly!!

Post Reply