javaautoitcmdline-args

How to put filename with spaces as parameter?


When I run my AutoIt script for a filename without spaces ("filename.txt") it gets executed successfully. But when filename contains spaces ("File Name.txt") I get error "File not found".

Parameterized.au3 :

ControlFocus("Open","","Edit1")
ControlSetText("Open","","Edit1",$CmdLine[1])
ControlClick("Open","","Button1")

Execution from Java:

Runtime.getRuntime().exec("C:\\Users\Screenshots\\Parameterized.exe" + " "
                + filePath);

filePath is passed as argument from another method :

filePath-> "C:\\Temp\\TMP\\TCs\\TC1\\Solution File.txt"

Solution

  • Take your file path into " so that your exec would look like:

    Runtime.getRuntime().exec("C:\\Users\Screenshots\\Parameterized.exe" + " "
                    + "\"" + filePath + "\"");