Client Management Suite

 View Only

Batch Script to Check and Install an Application Package 

Aug 28, 2013 12:47 PM

Here is a script template to install an application package. This sample script will install MSI along with TRANSFORM. When deploying the package [MSI+MST] via Altiris, it is always recommended to use a script rather than specifying the MSI commandline for deployment.

The script will check if the application is already installed on the machine, thus avoiding any reinstall issues. The application will get installed only if it isn't already installed on the machine. The verification logic is based on the UNINSTALL registry key [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall].

Also the script writes the installation success or failure to EVENT LOG, making it easy for the troubleshooting. Please note that UPN [Universal Package Name] is the unique representation of an application package.Usually UPN consists of Application ID [for tracking], Application Name, Vendor Name, version and release version of the package. This depends on the project that you are working.

 

REM ===================DEFINE MSI,MST,UPN,log file & folder here ==================
SET MSINAME=SETUP.MSI
SET MSTNAME=SETUP.MSI
sET UPN=AppID-Vendor-AppName-Version-ReleseVersion
SET LOGSFOLDER="C:\ApplicationLogs\%UPN%_Install.log"
IF NOT EXIST "C:\ApplicationLogs" MD "C:\ApplicationLogs"
REM ================================================================================
REM ===================Check if the Product exists already==========================
SET PRODUCTKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall
REG QUERY %PRODUCTKEY%\{4ECF4BDC-8387-329A-ABE9-CF5798F84BB2}
IF NOT %ERRORLEVEL% EQU 0 (GOTO :INSTALL) ELSE GOTO :ENDHERE  
REM ================================================================================
:INSTALL
REM =======================Install  the application=================================
MSIEXEC.EXE /I "%~dp0SETUP.MSI" /TRANSFORMS="%~dp0SETUP.MST" /QB! /L*V "%LOGSFOLDER%"
set MSIERROR=%errorlevel%
if %MSIERROR%==0 GOTO :ENDHERE
if %MSIERROR%==1641 GOTO :ENDHERE
if %MSIERROR%==3010 GOTO :ENDHERE
GOTO :ERROR
REM ================================================================================
REM ================ Installation successful. Write to Event Log====================
:ENDHERE
EVENTCREATE /l Application /so %UPN%-Install-SUCCESS /t SUCCESS /id 1000 /d "Application installed successfully."
Exit 0
REM ================================================================================

REM ================ Installation failed. Write to Event Log========================
:ERROR
EVENTCREATE /l Application /so %UPN%-Install-FAILED--(ERROR=%MSIERROR%) /t ERROR /id 999 /d "Application installation failed."
Exit %MSIERROR%
REM ================================================================================

 

Please change the variables according to your requirement before implementing. Hope this helps.

 

Statistics
0 Favorited
0 Views
1 Files
0 Shares
0 Downloads
Attachment(s)
txt file
InstallApplication.bat_.txt   1 KB   1 version
Uploaded - Feb 25, 2020

Tags and Keywords

Related Entries and Links

No Related Resource entered.