我在试图运行bfgminer.exe -o bla.bla.com -u <nick> -p <passwd> -S auto -d all
我尝试了多种方法来运行此可执行文件,但我无法让它工作:
public static void runCmd(){
try{
ProcessBuilder builder = new ProcessBuilder("cmd.exe","/c", "cd \"C:\\Users\\pawisoon\\bfgminer-3.10.0-win64\" && bfgminer.exe -o bla.bla.com -u <user> -p
<pswd> -S auto -d all");
builder.redirectErrorStream(true);
Process pd = builder.start();
BufferedReader r = new BufferedReader(new InputStreamReader(pd.getInputStream()));
String line;
while (true) {
line = r.readLine();
if (line == null) { break; }
System.out.println(line);
}
}
catch(IOException e){
}
}
这是我在Eclipse中从控制台获得的内容:
'bfgminer.exe' is not recognized as an internal or external command,
operable program or batch file.
请帮我解决这个问题:/
答案 0 :(得分:1)
非常感谢您的回答!我结合了你的建议并且它有效。这是代码:
public static void runCmd(){
File f = new File("C:\\Users\\pawisoon\\bfgminer-3.10.0-win64");
try{
ProcessBuilder builder = new ProcessBuilder("cmd.exe","/c","start","bfgminer.exe", "-o", "bla.bala.com", "-u", "user", "-p", "lelelel", "-S", "auto", "-d", "all");
builder.directory(f);
builder.redirectErrorStream(true);
Process pd = builder.start();
BufferedReader r = new BufferedReader(new InputStreamReader(pd.getInputStream()));
String line;
while (true) {
line = r.readLine();
if (line == null) { break; }
System.out.println(line);
}
}
catch(IOException e){
}
}
答案 1 :(得分:0)
从我看到的,你试图执行
cd C:\Users\pawisoon\bfgminer-3.10.0-win64\
然后
bfgminer.exe -o bla.bla.com -u -p -S auto -d all
因为我认为bfgminer.exe位于支持的实际库中(C:\ Users \ pawisoon \ bfgminer-3.10.0-win64)
但实际上我不确定你的两个cmd命令是否正确执行(我的意思是:我不确定该库是否作为执行第二个命令的参考)
那么为什么不尝试执行
C:\Users\pawisoon\bfgminer-3.10.0-win64\bfgminer.exe -o bla.bla.com -u -p -S auto -d all
(没有cd和可执行文件的完整路径)
或者查看@ginz评论并尝试直接启动可执行文件(不使用cmd)如果您不特别想使用cmd.exe