点击按钮 提交action到后台 运行java代码如下 public class Exec { public static void main(String[] args) { try{ Process p=Runtime.getRuntime().exec ("c:\\Program Files\\Tencent\\QQ\\Bin\\QQ.exe"); //这里是你的程序的绝对路径,你也可以将QQ路径加入到Path 环境变量里,可以直接运行exec("QQ"); p.waitFor(); }catch(Exception e){ } } }
IE下用JS脚本打开QQ,路径中的空格要用%20<script> function openQQ(){ var shell = new ActiveXObject("wscript.shell"); shell.run("file:///D:/Program%20Files/Tencent/QQ/Bin/QQ.exe"); } </script> <button onclick="openQQ();">打开QQ</button>
public class Exec {
public static void main(String[] args) {
try{
Process p=Runtime.getRuntime().exec
("c:\\Program Files\\Tencent\\QQ\\Bin\\QQ.exe");
//这里是你的程序的绝对路径,你也可以将QQ路径加入到Path 环境变量里,可以直接运行exec("QQ");
p.waitFor();
}catch(Exception e){
}
}
}
function openQQ(){
var shell = new ActiveXObject("wscript.shell");
shell.run("file:///D:/Program%20Files/Tencent/QQ/Bin/QQ.exe");
} </script>
<button onclick="openQQ();">打开QQ</button>