Showing results for 
Search instead for 
Did you mean: 

Alteryx Designer Knowledge Base

Definitive answers from Designer experts.

The highly anticipated Alteryx Community tradition is back! We hope you'll join us!

Learn More
We will be upgrading the Gallery to our 2019.4 release this Saturday, December 7th beginning at 9:00am MT. We expect the outage to take last approx. 2.5 hours.

The Run Command: Write Source & Read Results

Alteryx Alumni (Retired)
Created on

RunCommand.pngThe Run Command tool is a great way to take your workflow to the next level of efficiency. It allows you to interact with the command line directly, just as you would if you were to access it manually and type in a command. Which is great because sometimes we have a lot of important things to do in the command line.




Exhibit A


This post will discuss two features of the Run Command tool: the Read Results and Write Source configuration options. You'll note that they both say "optional", but the Run Command expects one or the other to be configured (or both) and will error if they are blank. These options both deal with files that are either used in the command (Write Source), or created by the command (Read Results).


Read Results

Let's start with that second case - you have a command line command being carried out in the Run Command, and you want to spit out the results to your workflow. The Read Results option allows you to grab the output of your command and bring it into your Alteryx workflow.


If you stream anything out of the Run Command, you must configure the Read Results. You may wonder why you need a file to stream in the result from your command - Just remember this is all happening outside of Alteryx, so if you want to bring something back into Alteryx you need to treat it as a data source.


You can configure this like an Input Data tool, by clicking “Input…”.




The example here was taken right from our documentation on the tool, and shows how we can create a temporary file in the command, navigate to it in the Read Results, and have that pass into the workflow after the Run Command tool.


N.B. %temp% is a placeholder for your Designer's temporary path, usually something like C:\ProgramData\Alteryx\Engine\blahblahblah. See this article for more information on Workflow Constants.


Write Source

This option would allow you to take some information from your workflow and incorporate it as a source in your command, sort of like how Neo suits up in the Matrix.



Actually, it's exactly like that.


The example I included on this article uses a field in Alteryx with the entire command, and then writes that to a temporary .bat file. The Run Command then simply reads the batch file and executes the command. I also included a Read Results here so we can see the output in the workflow, but it isn’t necessary.


Just like before, if you stream anything into the Run Command, even if you don't use it in the command itself, you must also have the Write Source configured.


write source.PNG



Troubleshooting Tips


1. Errors:


Sometimes you may get a weird error from the Run Command that is actually just being passed along from the command line. Most of the time these will tell you where they're from, and they will almost always just be pointing at something wrong in your Command Arguments.




These will usually have a error code associated with them as well - these are actually Windows error codes, so you may be able to find some more information by Googling around.


2. Input Schema:


Depending on the data you're bringing in, you may need to play with your Input Tool configuration to account for header rows, or wonky metadata. To get around these sort of things, try to treat your data as non-delimitted by configuring your Input as below:


input config.png


We’ll just have to make sure that our delimiter is set to \0 and that we don’t have the First Row Contains Field Names option checked. The "\0" is just a shortcut to tell Alteryx to use no delimiter when parsing fields – so all the text will come in natively separated only into rows. The “long way” is brought up in the Resolve File Type window that will pop up if you use a file type that is not in the drop down menu of the Input Tool configuration.


Thanks for reading! 


Example workflow compiled in Alteryx Designer 10.6.




I am trying to run a VBScript using the run command, but I get an error standing that it failed as it is not a valid Win32 application. Is there a workaround for this or does this specific tool only support .bat and .exe files?


Thank you!



ACE Emeritus
ACE Emeritus

Hi Liz -- can you try "CScript <scriptFilename>" as the command you're running?


Hi John, just tried your suggestion but got a different error stating "the system cannot find the file specified".

ACE Emeritus
ACE Emeritus

I'm not sure if that means it can't find CScript or if CScript can't find the file.... could you try adding the full path to your scrip filename?


Actually we created a .bat file that ran the VBScript and that worked! Thank you either way! 


I'm not sure if this is due to an update or what, but I couldn't find the file using %temp%/filename with my Python code.  I ended up having to walk through the engine directory to find the file and bring it into the script.  Here's what ended up working:


 rootdir = r'C:\ProgramData\Alteryx\Engine'

    for root, dirs, files in os.walk(rootdir):
        for file in files:
            if file == 'MYFILENAME': # use your filename here without file type extension
                filepath = os.path.join(root, file) 
                print filepath

Just thought I'd throw that out there if anyone else had that issue.


Hello @AlexKo and Fellow Community Users,


I am developing a workflow that uses the Run Command Tool to execute a Batch program. I have been testing the execution of the Batch program directly on Windows Command Line where it is throwing an error. 


However, when I run the workflow that uses the Run Command Tool to execute this batch program, it keeps on running without throwing an error. Can somebody provide few ideas on how to make the workflow stop and capture the error that this batch program is throwing in a log file.


As of now, I could not find a configuration for Run Command Tool that could enable me to capture the error message.




Alteryx Certified Partner

My run command tool workflow works as a normal workflow with %temp%\statfin-Dynamic_Query.bat but when I turn it into a macro, it cannot find the bat file anymore.


Anyone got run command tool working within a macro?


Write source path: %temp%\statfin-Dynamic_Query.bat


Run External Program Command:



Working directory:



Read results:



I think I tried all possible %path% combinations and cannot understand why it does not work. When I navigate to temp file and run the .bat it generates a csv out of jsonstat file.



This saved me! Thanks!