Pre-command error ignored
I have a backup task configured with a pre-command that executes a batch script with both options selected:
- Do not perform operations until the command's execution is complete
- Abort the operation if the user command fails
If the script fails it exits with error code 1 which should cause the task to abort. However the task still runs. The TI_demon log contains the following messages:
E00010400: Child process has exited with code '1'. I00640086: Execution of user command succeeded: Pre_Backup_Check.cmd
If the script succeeds it exits with error code 0 and the task runs as expected. In this case the TI_demon log contains the following messages:
I00010400: Child process has exited with code '0'. I00640086: Execution of user command succeeded: Pre_Backup_Check.cmd
Note that the initial character of the "Child process" message code is "E" on error and "I" on success. It looks like TI is not taking any notice of that.


- Log in to post comments

Tested this on ATI 2019 #17750 and looks to be working fine for me using a simple Pre Command batch script.
The script was as shown above and contained the following test for my normal IP address.
@echo off set myAddress=192.168.0.13 for /f "tokens=1-2 delims=:" %%a in ('ipconfig^|find "IPv4"') do set ip==%%b set ipAddress=%ip:~1% ::echo IP Address : %ipAddress% if %ipAddress%==%myAddress% goto atHome echo "Away from Home!" echo IP Address : %ipAddress% timeout /t 10 exit /b 1 :atHome echo "Still at Home" echo IP Address : %ipAddress% timeout /t 10 exit /b 0
For the test, I just set a different 'myAddress' IP address instead of my normal one (13 not 11).
The task using this Pre Command then aborted the backup on the error thrown when the IP address did not match.
- Log in to post comments

I updated to build 17750 and got the same result. My batch script is even simpler than yours and sets the exit code in exactly the same way using "exit /b n" where n is 0 on success and 1 on error.
I noticed that your script had a .bat extension, so I renamed mine from .cmd to .bat and TI correctly detected the failure:
E00010400: Child process has exited with code '1'. E00640085: Execution of user command Pre_Backup_Check.bat failed. Error code:1 E013C0005: Error 0x13c0005: Operation has completed with errors.
It looks like TI is handling .bat and .cmd exit codes in subtly different ways.
- Log in to post comments

Alastair, it has been noted previously that ATI can handle BAT and CMD scripts slightly differently, so always worth trying each in turn if you don't see the expected behaviour.
I tend to default to using BAT scripts and try to keep these as simple as possible when used as either Pre or Post Commands, anything more complex I do in PowerShell and run the scripts outside of ATI instead.
- Log in to post comments

Steve Smith wrote:Alastair, it has been noted previously that ATI can handle BAT and CMD scripts slightly differently, so always worth trying each in turn if you don't see the expected behaviour.
Thanks Steve, that's a good tip. In all my years of using TI I hadn't realised there was any difference, but this is possibly the only time I have wanted to force a failure for a particular condition.
- Log in to post comments

I ended up raising a support case for this, part of which required me to document my observations. In summary:
-
.cmd scripts are executed by cmd.exe with any output shown in the resulting Command window. Exit codes are ignored by TI.
-
.bat scripts are executed by TrueImage.exe and no output is shown in the resulting Command window. Exit codes are recognised by TI.
The only way to get consistent results from both types including capturing output is to specify the command as cmd.exe and the arguments as
/c script-name.type >> log-file 2>&1
I have asked Acronis if they can explain the difference.
- Log in to post comments

Thanks for the update Alastair.
- Log in to post comments

Steve Smith wrote:Alastair, it has been noted previously that ATI can handle BAT and CMD scripts slightly differently, so always worth trying each in turn if you don't see the expected behaviour.
Actually, Windows handles the execution of .cmd and .bat scripts differently - something about setting the ERRPRLEVEL variable. I don't understand a thing I've read about it, but the difference obviously matters to ATI. Most things I've read recommend using .CMD (because it's newer, I guess) but we need to ignore that recommendation for ATI Pre commands.
I suspect it doesn't matter much for Post commands since that would not effect the ATI functioning.
- Log in to post comments