Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Run command with batch file working but error code 1 is showing

wonka1234
10 - Fireball

I have a run command script that copies a file to a new location... How come the result is fine but still getting error code 1? Is there a known way to see what this means?

 

wonka1234_0-1682455406354.png

 

6 REPLIES 6
PhilipMannering
16 - Nebula
16 - Nebula

Can you share the workflow?

SPetrie
13 - Pulsar

Are you using robocopy in your command by chance?

Generally, a batch file exit code 1 means something went wrong, but robocopy uses exit code 1 to mean that a file was copied successfully which can cause confusion.

You can append EXIT /B as the last line of your batch file to exit the batch file before exit codes are report and it should clear that error.

 

wonka1234
10 - Fireball

@SPetrie i dont use robocopy - but using the EXIT B/ seems to get rid of the error.. do you know why?

SPetrie
13 - Pulsar

Its the same reasoning even if you dont use Robocopy. Robocopy is just the normal culprit that I see.

The EXIT command terminates the batch script and /B allows us to set an error code. With no code afterwards, its just jumping to the end of the batch file and closing the cmd window without altering the error level/exit code.

Be aware that this code may prevent actual errors from being reported back to your run command tool.

It is a bit odd if you are not using Robocopy that you are getting an exit code of 1. Usually that means that something at least partially went wrong. 

If you run the batch in a regular cmd window without alteryx, are there any error messages that pop up?

 

 

wonka1234
10 - Fireball

@SPetrie no error msgs outside alteryx. Its just moving a file/copying a file.

SPetrie
13 - Pulsar

@wonka1234 The only other things I can think of that would cause that error on a successful copy, is in how the commands are being written to the batch file.

When you set it up, is it saving the batch as a csv with no delimiters?

SPetrie_0-1682626009997.png

 

Try opening the batch that is created and see if that has any odd characters in it. 

SPetrie_1-1682626159653.png

You can run the created batch to see if it generates any errors as well. You can edit the file and add "Pause" as the final command to keep the window open until you enter a keystroke.

 

You can also try to output the results directly from the batch as well to see if it indicates anything strange using output commands

copy c:\filelocation\test.txt c:\destination > c:\testresults\result.txt
echo "The error level is %errorlevel%"> c:\testresults\errorlevel.txt

 

Beyond that, Im not sure why it would give you the issues and would need to see the batch created by alteryx.

You can also, if you are confident that its actually doing what you want, leave the Exit /B in the code to simply skip the errors and move about your day.

That call is up to you though.

Labels
Top Solution Authors