You can use the additional argument below in your script to check the status of the job phase before running the script and then act accordingly based on the return code. (note code "4" which is: The job was killed while executing that phase and "2" which is: The phase failed)
Whereas i cannot write the script for you if you add these factors correctly you can have it only run if the job completes successfully. So basically it an aded argument to your batch file that can account for the failure or killed job status.
For Windows, a Pre/Post command that is a batch file needs to be run using the command interpreter cmd.exe /C.
||c:\winnt\system32\cmd.exe /C ""c:\program files\pre.bat" "test set""
In addition to the specified Pre/Post commands, the CommServe sends additional arguments and appends them to the Pre/Post commands (if any); this can provide a useful means of control based on the type of job being run. You can use the value of the argument(s) within Pre/Post batch files or scripts to run specific operations based on the level, number of attempts, or status of the job (e.g., for Unix, by issuing an echo command or including a case statement within the appropriate script). These arguments include the following:
||where "n" is one of the following values indicating the status of the phase that preceded a given Post process within a given job: (This will be passed to all Post processes, but not to Pre processes.)
||The phase succeeded
||The phase failed
||The phase succeeded with one or more errors
||The job was killed while executing that phase
||Example: If you want to run a Post process (e.g., PostBackup) only if the preceding phase (e.g., Backup) was a success, you can test the value of the "status" argument received by the Post process and take the appropriate action.