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 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进行打印