Need uninstall .bat file to signal success when product does not exist
My situation is this. I am deploying Navisworks Freedom 2015 to PCs using SCCM 2012, some of which have 2014, others do not. The install signals reboot required and will reboot no matter what if its part of a Task Sequence, so I need to deploy it as a Package/Program which allows me to set the reboot behavior to never and avoid the automatic reboot, which I have to avoid in this deployment.
The problem is, I can't set conditions for the batch file that runs the uninstall for the previous version to only run if the previous version exists. So I need to force the batch file to run whether or not the app exists and send a error code of 0 to SCCM in order to continue the installation of the latest version.
Specifically, I get error codes 1605 and 255 when I try to run on a machine that does not have 2014 installed. Although it may not be best practice, I have attempted to script the errorlevel behavior in the batch file such that if either of those codes appear it still instructs the script to send a Success error code.
msiexec /uninstall %product_code% %uninstallation_mode%
if %errorlevel%=1605 goto SUCCESS_
if %errorlevel%=255 goto SUCCESS_
if %errorlevel%==%msi_ERROR_SUCCESS% goto SUCCESS_
::print out Machine Name, product code, product name
::to the network log file for the product that failed to uninstall
set uninstallation_result=Failed, Result=%errorlevel%
echo %Date% %Time% %USERNAME% %COMPUTERNAME% Uninstall %product_name% (Product Code: %product_code%) %uninstallation_result% >> %network_log_file_path%