How to put filename with spaces as parameter?

156 Views Asked by At

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"
1

There are 1 best solutions below

0
On BEST ANSWER

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

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