当我从命令提示符执行sigcheck时,我得到了正确的结果。但是当我在代码的帮助下执行时,结果是不同的。
结果从命令提示符执行时:
Hello in if LOOP
Verified: Unsigned
Publisher: n/a
Company: n/a
Verified: Unsigned
Publisher: n/a
Company: n/a
结果从代码执行时:
chrome.exe 3024控制台1 4,452 K正在运行
以下是命令的标准输出:
public void verifysignature(String filepath) {
String s = null;
try {
filepath= "\""+filepath+"\"";
System.out.println("This is file path " + filepath);
Process p = Runtime.getRuntime().exec("c:\\sigcheck.exe -vt " +filepath); //
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
System.out.println(" hello " +stdInput);
BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));
// read the output from the command
System.out.println("Here is the standard output of the command:\n");
while ((s = stdInput.readLine()) != null) {
/*System.out.println(s + "This is the S");*/
if(s.contains("Verified:") || s.contains("Publisher:") || s.contains("Company:"))
{
sb1.append(s).append("\n");
System.out.println("Hello in if LOOP");
/*System.out.println(s);*/
System.out.println(sb1);
}
}
// read any errors from the attempted command
System.out.println("Here is the standard error of the command (if any):\n");
while ((s = stdError.readLine()) != null) {
System.out.println(s);
sb.append(s).append("\n");
}
}
代码:
ClassCastException
答案 0 :(得分:0)
将文件路径也作为命令的一部分。 String cmd =“sigcheck64.exe -h someapp.exe”; 进程p = Runtime.getRuntime()。exec(cmd);