Sam
Sam

Reputation: 72

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"

Upvotes: -1

Views: 183

Answers (1)

Alexey R.
Alexey R.

Reputation: 8686

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

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

Upvotes: 1

Related Questions