windows 使用 Java 在远程系统上执行批处理文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7346907/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Executing batch file on remote system using Java
提问by Abhinav Garg
How to execute a batch file located on Windows remote system? Batch file should run on remote system.
如何执行位于 Windows 远程系统上的批处理文件?批处理文件应该在远程系统上运行。
回答by Santosh
Abhinav, For your problem I see RMI is the quickest possible solution
Abhinav,对于您的问题,我认为 RMI 是最快的解决方案
回答by Peter Lawrey
Another approach is to use SSH like sshj. This only requires the remote system to have SSH installed and is more secure than RMI.
另一种方法是像 sshj 一样使用 SSH。这只需要远程系统安装 SSH 并且比 RMI 更安全。
回答by nIKUNJ
You can use Jschand Expect4jfor executing commands on remote machine(window/Linux). Further more, if your system allows, transfer the batch file on remote machine using some FTP utility like Apache Commons Netand then execute commands that executes the script.
您可以使用Jsch和Expect4j在远程机器(window/Linux)上执行命令。此外,如果您的系统允许,请使用某些 FTP 实用程序(如Apache Commons Net)在远程计算机上传输批处理文件,然后执行执行脚本的命令。