您的位置:首页 > 其它

IE和Firefox下执行exe程序

2012-07-24 16:10 218 查看

IE 下执行exe程序 (ActiveX)

<a href="javascript:LaunchApp()">Click
here to Execute your file</a>

<script>

function LaunchApp() {

if (!document.all) {

alert ("This ActiveXObject is only available for Internet Explorer");

return;

}

var ws = new ActiveXObject("WScript.Shell");

ws.Exec("D:\\Software\\youfile.exe");

}

</script>

Firefox 下执行exe程序

<a href="javascript:LaunchApp()">Click
here to Execute your file</a>

<script>

functionLaunchApp() {

netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');

var file=Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);

file.initWithPath("D:\\Software\\yourfile.exe");

file.launch();

}

</script>

例子:如果exe带参数则var args = ["argument1", "argument2"];

var file = Components.classes["@mozilla.org/file/local;1"]
.createInstance(Components.interfaces.nsILocalFile);
file.initWithPath("c:\\myapp.exe");

// create an nsIProcess
var process = Components.classes["@mozilla.org/process/util;1"]
.createInstance(Components.interfaces.nsIProcess);
process.init(file);

// Run the process.
// If first param is true, calling thread will be blocked until
// called process terminates.
// Second and third params are used to pass command-line arguments
// to the process.
var args = ["argument1", "argument2"];
process.run(false, args, args.length);

如:var arguments = ["-h","10.20.65.41","-p","5901","-w","11111111","--title","1111"];

积累:

var WSS = new ActiveXObject("WScript.Shell");
WSS.RegWrite("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows\\Device","pdfFactory Pro,winspool,FPP2:");

var WSS = new ActiveXObject("WScript.Shell");
WSS.RegWrite("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows\\Device","pdfFactory Pro,winspool,FPP2:");
这个需要是来源于客户端设置打印机,并直接通过applet进行打印
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: