External Tool Node. Paths with spaces produce errors

Hi,

I use Knime version 2.9.2. The external tool node (in Misc section of nodes) produces the following error message when a path to executable contains spaces.

External tool Node configuration:

Input file to external tool --> C:\Program Files (x86)\KNIME_TEMP\input.csv

Path to Executable --> C:\Program Files (x86)\KNIME_TEMP\test.bat

Execute in directory --> C:\Program Files (x86)\KNIME_TEMP

Output file from external tool --> C:\Program Files (x86)\KNIME_TEMP\output.csv

 

If I use these settings and try to run the node I get the following error message:

ERROR     CommandExecution                   Execution failed (with exception): Cannot run program "C:\Program" (in directory "C:\Program Files (x86)\KNIME_TEMP"): CreateProcess error=193, %1 is not a valid Win32 application
ERROR     External Tool                      Execute failed: Cannot run program "C:\Program" (in directory "C:\Program Files (x86)\KNIME_TEMP"): CreateProcess error=193, %1 is not a valid Win32 application

Everything seems to work fine as soon as there no spaces in the "path to executable" option. For example, if I specify Path to Executable as C:\KNIME_TEMP\test.bat

(I created a new folder on C drive and copied test.bat there), then there are no problems in running External tool node (Please note that all other setting remained the same, i.e. with the paths C:\Program Files (x86)\KNIME_TEMP)

I also tried to work around the problem and include quotes in the path to executable, e.g.:

C:\"Program Files (x86)"\KNIME_TEMP\test.bat

"C:\Program Files (x86)\KNIME_TEMP\test.bat"

C:\Program%20Files%20 (x86)\KNIME_TEMP\test.bat

'C:\Program Files (x86)\KNIME_TEMP\test.bat'

C:\'Program Files (x86)'\KNIME_TEMP\test.bat

and alike.

In every case I get another error message:

Invalid settings:

The specified external executable (C:\"Program Files (x86)"\KNIME_TEMP\test.bat) doesn't exist!

Does anyone have any ideas how to deal with paths which contain spaces in the "Path to Executable" option? The ideas such as: "Don't use spaces" are not accepted.

I would very much appreciate your replies.

Best,

/Aleksejs

Dear Aleksejs,

I tried to reproduce this and it works for me. In 2.9.2 I configured the External Tool node with the executable 

C:\Program Files (x86)\Notepad++\notepad++.exe

(like that - no quotes), and it executed with no error. I don't know why it doesn't do it for you. You could try out the other external tool node (from Labs), maybe that works for you (you need to enter the path with forward slashes there).

Best regards,

 - Peter.

You could also try putting " " around the paths with spaces in

Steve

Dear Peter,

Thank you for you reply and a valuable suggestion. It seems to me strange that the External Tool node behaves differently on different PCs running the same Knime version. I still could not manage to run executables from External Tool node if the a path contains spaces.

However, I managed to run External Tool Node from Labs as you suggested, where the path to executable is specified with spaces. In this node if the path is specified as

C:\\"Program Files (x86)"\\KNIME_TEMP\\test.bat

- the node perfoms the job! :)

The main inconvenience is that External Tool node from Labs writes down row ID numbers to the input file to executable and also requires row IDs to be present in the output file produced by the executable. This means that I have to modify all my batch files which I normally used to run from original External Tool Nodes in a way that rowID column is removed first and then added back before the output file is feeded back to Knime. This is fine when you have juat few External tool nodes to be replaced, however, it becomes real headache if have up to 100+ External tool nodes to replace in various workflows.

Thus, I kindly urge you to fix the issue in the next version of Knime release, if possible.

Once again I thank you for a useful advice and your reply.

Best regards,

/Aleksejs

Dear Steve,

I have tried various ways to quotes ("" and '') around the paths with spaces and the result was the same. It does not matter where and how I put single or double quotes I get the same error message saying that:

The specified external executable ("C:\"Program Files (x86)"\KNIME_TEMP\test.bat") doesn't exist.

(the path in the error message changes depending on what is currently entered in the External Tool node "Path to executable" field)

I tried to "play" with the quotes in the path (thouroughly) before I decided to write a post in Knime Tech Forum and seek for help.

If you come up with suggestions on how to put quotes in the path with spaces so the External Tool node accepts it, I would truly appreciate that! :)

Kind regards,

/Aleksejs