简体   繁体   English

如何将带空格的文件名作为参数?

[英]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.当我为一个没有空格的文件名(“filename.txt”)运行我的 AutoIt 脚本时,它被成功执行。 But when filename contains spaces ("File Name.txt") I get error "File not found".但是当文件名包含空格(“File Name.txt”)时,我收到错误“找不到文件”。

Parameterized.au3:参数化.au3:

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

Execution from Java:从 Java 执行:

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

filePath is passed as argument from another method: filePath作为另一个方法的参数传递:

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

Take your file path into " so that your exec would look like:将您的文件路径放入"这样您的exec看起来像:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM