I found a couple of old threads that mentioned people had problems with this as well, but I haven’t been able to find an answer. I have a few wait commands in my task where if they don’t return an exit code of 0 I want to run another command, then exit the action. Below is a simplied example of what I’m trying to do. (I added the prefetch command in here, because others mentioned this works if you don’t have any downloads in the action).
That’s what I was thinking the problem was. It seems if you have download statements (or prefetch) in your action the client evaluates all “if” statements prior to running. The exit code of the action obviously wouldn’t exist until after the action was running. So I added an “if exist exit code of action then else” statement and was able to get this to work. One thing to mention is even though the client evaluates the if statements (and parameters) prior to running the action, it will evaluate them again during the action. So in my case the exit code parameter is evaluated prior to running, and must not contain errors, however it will evaluate again when that line is reached in the action, so the correct exit code is set. I used parameters for the exit code in order to retrieve it in the console in the event of failure, example below.
waithidden run.cmd
parameter “Exitcode” = “{if exist exit code of action then exit code of action as string else “52311”}”
if {parameter “Exitcode” != “0”}
//Run.cmd did not complete as expected. Now run run2.cmd and exit the task with the exit code from run.cmd
I was under the impression that parameters were always evaluated before execution and never changed once set, which would suggest this would never work.
I just tested it and it works (exit code parameter set to 0). I’ve been using paramaters that are set based on things that happen in the action for a while… They seem to be evaluated prior to running (to check for errors and to determine what downloads are needed), but then again during the task.
Thanks for that info, I’ll have to take a closer look at parameter behavior. Perhaps I’m confusing the problems I’ve run into if you try to set a parameter more than once in actionscript with this.