Alteryx Designer

Definitive answers from Designer experts.

Auto Answer Y or N in Run Command


There are some command line statements that require you answer Y (yes) or N (no) before the statement will completely execute.  Case in point: let's say I want to delete files that are in a particular directory to clean up any files I no longer need (e.g. they are temporary work files), and I want to do this using a Run Command tool.


So I drag and drop a Run Command tool to my canvas.  




And I configure the tool:




Since the Run Command is a stand-alone tool, I have to select 'dummy' output and input files.  In the command line I point to where command line executable file is located (C:\Windows\System32\cmd.exe in my case).  Then I add my command arguments.  '/C' carries out the command specified and then terminates.  DEL is the command to delete files and I specify the path where the files are located.  '*' is a wildcard character that will allow me to delete all the files in that path.


When I run the workflow, I get prompted with a question which requires a manual answer/input from me. 




If I had set this up to run minimized and/or in silent mode, it is possible I wouldn't know I was being prompted for an answer.  How can you answer 'Y' in the command prompt automatically?  You need to turn echo off.  This can be done by adding '/Q' in the Command Argument like this: 




Now when you run the workflow, it will automatically answer 'Y' and delete your files.


As an added bonus, there are many of these '/?' commands that can come in handy.  Here is a list of the more commonly used commands:


/C      Carries out the command specified by string and then terminates
/K      Carries out the command specified by string but remains
/S      Modifies the treatment of string after /C or /K (see below)
/Q      Turns echo off
/D      Disable execution of AutoRun commands from registry (see below)
/A      Causes the output of internal commands to a pipe or file to be ANSI
/U      Causes the output of internal commands to a pipe or file to be
/T:fg   Sets the foreground/background colors (see COLOR /? for more info)
/E:ON   Enable command extensions (see below)
/E:OFF  Disable command extensions (see below)
/F:ON   Enable file and directory name completion characters (see below)
/F:OFF  Disable file and directory name completion characters (see below)
/V:ON   Enable delayed environment variable expansion using ! as the
        delimiter. For example, /V:ON would allow !var! to expand the
        variable var at execution time.  The var syntax expands variables
        at input time, which is quite a different thing when inside of a FOR
/V:OFF  Disable delayed environment expansion.