computing
  • 27

Batch file to install msi and check errorlvl

  • 27

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:XenAppxenapphosted.msi /qn /norestart /l*v c:XenAppinstall.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

:OK
cscript C:XenAppHostedrenameicafolder.vbs
copy C:XenAppappsrv.ini C:”Program FilesCitrixICA Client” /y
copy C:XenAppmodule.ini C:”Program FilesCitrixICA Client” /y
copy C:XenApppn.ini C:”Program FilesCitrixICA Client” /y
reg.exe import C:XenApppnsson.reg
GOTO END

:err

rem print message and return errorlevel so package errors

echo “Error: Msiexec failed with errorlevel = %errorlevel%”

exit /b %errorlevel%

:END

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.

Share

1 Answer

  1. 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?
    HTH.
    Ed in Texas.

    • 0