我正在本地(Linux)和远程Selenium节点(Windows)上运行自动化测试。我想删除一个在测试期间创建的文件夹,使用Java Runtime.getRuntime().exec。它在本地(Linux)上运行得很好,但我很难在Windows节点上找到如何做到这一点。以下是我的尝试:
try {
if (rBundle.getString("RUN_ON").equalsIgnoreCase("local")) // delete folder temp on local (Linux) - it works
Runtime.getRuntime().exec("rm -rf " + System.getProperty("user.home") + "/Temp");
else // delete folder C:/Temp on remote Windows
Runtime.getRuntime().exec("rm -rf IEUser@10.2.2.240/C/Temp");
// Runtime.getRuntime().exec("rm -rf //10.2.2.240/C/Temp");
} catch (IOException e) {
e.printStackTrace();
}我尝试删除远程Windows上的文件夹C:/Temp,但没有任何成功。我没有任何例外,它穿过了那个街区。很明显,命令行错了,但我不知道。
任何帮助都很感激。谢谢
发布于 2018-05-14 04:56:41
rm是windows is del命令上用于Linux命令行的一个命令:
C:\>del /?
Deletes one or more files.
DEL [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names
ERASE [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names
names Specifies a list of one or more files or directories.
Wildcards may be used to delete multiple files. If a
directory is specified, all files within the directory
will be deleted.
/P Prompts for confirmation before deleting each file.
/F Force deleting of read-only files.
/S Delete specified files from all subdirectories.
/Q Quiet mode, do not ask if ok to delete on global wildcard
/A Selects files to delete based on attributes
attributes R Read-only files S System files
H Hidden files A Files ready for archiving
I Not content indexed Files L Reparse Points
- Prefix meaning not若要删除文件夹,请使用:
DEL /F /S /Q /A "Full Path of Folder\*"https://stackoverflow.com/questions/50177855
复制相似问题