Wednesday 1 July 2015

Using Batch File To Check The OS Architecture

Today is a interesting day, whereby client wanted to deploy 2 versions Java (32 and 64 bits) to client machines.


One of the easier method is to use "Platform requirements" under Package:







and the other deployment method, choose "Requirements" under Application deployment to allow the package to detect the OS architecture of the client to install the appropriate version of the software.


The above method works fine, if you deploy just a 32 bit application, or you could exclude the OS versions. But you what if you have specific requirements that you need to deploy the 32 and 64 bits applications to respective OS? Well you could deploy two times or you use the following batch file to deploy: 

=====================================
@echo off
SET LogLoc=C:\LOGS
SET AppName=JAVA83_Install

IF NOT EXIST "%LogLoc%" (
MKDIR "%LogLoc%"
ECHO %DATE% %TIME% - %LogLoc% created >> %LogLoc%\%AppName%.log
) ELSE (
ECHO %DATE% %TIME% - %AppName% started >> %LogLoc%\%AppName%.log
)

IF EXIST "C:\Program Files (x86)" ("amd64/03-Java83.exe" /s) else ("x86/03-Java83.exe" /s)

ECHO %DATE% %TIME% - checking processor architecture - %CPUArch% >> %LogLoc%\%AppName%.log
ECHO %DATE% %TIME% - Starting JAVA 8 U31 Installation on %computername% >> %LogLoc%\%AppName%.log
SET ErrorCode=%ERRORLEVEL%
ECHO %DATE% %TIME% - Exit Code is - %ErrorCode% >> %LogLoc%\%AppName%.log
ECHO %DATE% %TIME% - Exiting Installation >> %LogLoc%\%AppName%.log
Exit %ErrorCode%

pause

=====================================

Copy and paste the above batch command, save as "CMD" or "BAT" . Change the files location and application name on the highlighted portion and deploy it under "Package" and you are good to go. 

This lead me to think, can I use Powershell to achieve it instead? :) 

Give you guys a update soon, hope you guys like it. 

Have fun. 

SY


No comments:

Post a Comment