Batch file to install msi and check errorlvl

Citrix Metaframe xp (product upgrade)
August 25, 2009 at 22:04:45
Specs: Windows XP
Hi Guys,
I'm trying to create a batach file that upgrades icaclient but if its being used to return an error and exit the batch file. If not being used it will upgrade the client. Here is my batch file:

@echo on

start /wait msiexec /i C:\XenApp\xenapphosted.msi /qn /norestart /l*v c:\XenApp\install.log

@echo off

echo "errorlevel = %errorlevel%"
if "%errorlevel%" == "0" goto OK
if "%errorlevel%" == "1013" goto err
if "%errorlevel%" == "1603" goto err
if not "%errorlevel%" == "0" goto err

cscript C:\XenAppHosted\renameicafolder.vbs
copy C:\XenApp\appsrv.ini C:\"Program Files\Citrix\ICA Client\" /y
copy C:\XenApp\module.ini C:\"Program Files\Citrix\ICA Client\" /y
copy C:\XenApp\pn.ini C:\"Program Files\Citrix\ICA Client\" /y
reg.exe import C:\XenApp\pnsson.reg


rem print message and return errorlevel so package errors

echo "Error: Msiexec failed with errorlevel = %errorlevel%"

exit /b %errorlevel%


But every time I run it it gives errorlvl = 0 and always completes. I can't get it to fail even though the install fails. What am I missing, please help.

See More: Batch file to install msi and check errorlvl

Report •

August 26, 2009 at 02:07:31
bsdtech, SWAG, I'm certainly not a batch file programmer. Been a few years since I did any programming, but strikes me you need to make another variable for the status value and alter your 'fail' statement to 'if not == "0" then...' then use it in your 'if' statements?
Ed in Texas.

Report •
Related Solutions

Ask Question