`

java 调起本地进程和杀掉本地进程

阅读更多
public static void openWinExe(String str) throws Exception {
StringBuilder sb = new StringBuilder();
String strCommand = "cmd /c start ";
sb.append(strCommand).append(str);
String ExePath = sb.toString();
Runtime runT = Runtime.getRuntime();

Process p = null;

try {
// String command="cmd /c start ";
p = runT.exec(ExePath);

} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("loader .exe error.......");
}

}
public static void main(String[] args)
{
     //举例
      Test.openWinExe("QQ.exe");
      Test.openWinExe("wmic process where name='QQ.exe' call terminate");
}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics