Run CMD Command in Workflow


I’m developing a workflow with the hopes of calling a CMD script during execution. In doing some research, I’ve seen plenty of articles\forums trying to achieve the opposite (running a workflow from Command Line).

To provide some context, my workflow connects to an AWS Athena database. However, in order to connect, the end user must complete a MFA. Buried in a long pathway is an executable file that completes the MFA processing. Instead of the user having to navigate the folder structure and then run the KNIME workflow, I want the executable to be called upon during the workflow execution. I have the command line script that calls the executable, I just need to figure out a way to open the CMD prompt and enter it automatically.

Athena Connection
Cloud Auth

Example CMD Script:
C:\Users\jgebhard> start (pathway to executable)

I’ve briefly experimented with the External Tool (Labs) node but it appears it’s function requires input data. I just need to open the Command Prompt window and run my script. Perhaps there’s a way to do this in Java but my background is predominantly in SQL and I haven’t been able to find the right recourse to help me code it.

Thanks in advance for any help or suggestions

Hi @JGebhard , you should be able to achieve this by adding the following node:

Alternatively, without installing additional nodes, if you create a command file (e.g. .cmd or .bat file) containing the script to be executed, you can open (execute) that using this component:

Configure "location type as “absolute path” and give it the full path to the cmd file, and tick the “Physically open location or execute file” option.

(I have workflows that do exactly that, e.g. for running gitlabs commands to check in a bunch of files that I have transferred in a workflow.)

Or if you are just calling an executable, you should be able to give it the full path of the .exe file, but if you are also passing parameters, then I would think creating the cmd file is the way to go. If it needs to be dynamic, there’s nothing to stop you actually creating the cmd file as part of your workflow of course… :wink:

1 Like

Brian, thanks so much…again haha! There really is a node for everything.

No worries if so, but I’m wondering if I can take it to the next step by auto filling the prompts within the executable. There’s really three steps to the MFA process

  1. Hit the “enter” key to select default username
  2. Type windows password, which I already have as a flow variable
  3. Type “0” to select basic role

Is it possible to implement these parameters automatically into the CMD? The questions are sequential too, so the windows password is keyed in after first hitting “enter”

Hi @JGebhard , I can’t think of a way of doing that “form filling” from KNIME (are you sure you cannot pass the user/password on the command line to the .exe? ) but if I were to be investigating that, I’d take a look at the utility “AutoHotKey”. You’d have to write an “.ahk” script for it which could probably do the key strokes for you. I’ve not tried it for this particular use case.

An example of an ahk script (for a totally different purpose) can be found at this post

Passwords are always a bit more problematic in such use cases, because at some point the password has to be passed in clear text, but if you have it in a flow variable, then it already is! Passwords are the bane of my “automated world” and I don’t have any good solution to that.

Interesting, I’ll have to give it a look. Thank you again

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.