判斷某個軟體是否已經啟動
阿新 • • 發佈:2019-02-07
public static boolean isStarted(){
boolean flag = true;
String com1 = " cmd.exe /c tasklist |find ";
String com2 = "\"1.exe\"" ;
String command = com1 + com2;
try {
Process ps = Runtime.getRuntime().exec(command);
BufferedReader reader = new BufferedReader(new InputStreamReader(ps.getInputStream()));
String str = reader.readLine();
if(str != null){
flag = true;
}else{
flag = false;
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("111111" + command + "------" + flag);
return flag;
}
boolean flag = true;
String com1 = " cmd.exe /c tasklist |find ";
String com2 = "\"1.exe\"" ;
String command = com1 + com2;
try {
Process ps = Runtime.getRuntime().exec(command);
BufferedReader reader = new BufferedReader(new InputStreamReader(ps.getInputStream()));
String str = reader.readLine();
if(str != null){
flag = true;
}else{
flag = false;
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("111111" + command + "------" + flag);
return flag;
}