我正在尝试使用以下命令。
Runtime.getRuntime().exec("netsh -c interface dump > c:\\location1.txt");但它不会产生任何输出。
我知道我们必须把命令和它的论点分开,我试过了,但还是失败了。
我用的是跟随的方式。
Runtime.getRuntime().exec("netsh",new String[] "-c", "interface", "dump >", "c:\\location1.txt");但仍然没有产出。
如果有人知道如何使用所有或一些使用运行时的NETSH命令,那么这将非常有帮助。
发布于 2014-01-08 09:31:29
您可以尝试使用ProcessBuilder
ProcessBuilder pb=new ProcessBuilder(command);
pb.redirectErrorStream(true);
Process process=pb.start();
BufferedReader inStreamReader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
while(inStreamReader.readLine() != null){
//do something with commandline output.
}发布于 2014-01-08 09:54:14
这是Windows上的netsh吗?尝试指定可执行文件的完整路径:
Runtime.getRuntime().exec("C:/full/path/netsh.exe",...https://stackoverflow.com/questions/20991254
复制相似问题