-1

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"
user4157124
  • 2,809
  • 13
  • 27
  • 42
Sam
  • 62
  • 8
  • Does this answer your question? [Use whitespace in Windows command line parameters](https://stackoverflow.com/questions/50625457/use-whitespace-in-windows-command-line-parameters) – user4157124 Nov 18 '22 at 13:54

1 Answers1

1

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

Runtime.getRuntime().exec("C:\\Users\Screenshots\\Parameterized.exe" + " "
                + "\"" + filePath + "\"");
Alexey R.
  • 8,057
  • 2
  • 11
  • 27