IE和Firefox下执行exe程序

IE 下执行exe程序 (ActiveX)

  1. <a href="javascript:LaunchApp()">Click here to Execute your file</a>
  2. <script>
  3. function LaunchApp() {
  4. if (!document.all) {
  5. alert ("This ActiveXObject is only available for Internet Explorer");
  6. return;
  7. }

  8. var ws = new ActiveXObject("WScript.Shell");
  9. ws.Exec("D:\\Software\\youfile.exe");
  10. }
  11. </script>

 Firefox 下执行exe程序

  1. <a href="javascript:LaunchApp()">Click here to Execute your file</a>
  2. <script>
  3. functionLaunchApp() {
  4. netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
  5. var file=Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
  6. file.initWithPath("D:\\Software\\yourfile.exe");
  1. file.launch();
  2. }
  3. </script>

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

  1. var file = Components.classes["@mozilla.org/file/local;1"]  
  2.                      .createInstance(Components.interfaces.nsILocalFile);  
  3. file.initWithPath("c:\\myapp.exe");  
  4.   
  5. // create an nsIProcess  
  6. var process = Components.classes["@mozilla.org/process/util;1"]  
  7.                         .createInstance(Components.interfaces.nsIProcess);  
  8. process.init(file);  
  9.   
  10. // Run the process.  
  11. // If first param is true, calling thread will be blocked until  
  12. // called process terminates.  
  13. // Second and third params are used to pass command-line arguments  
  14. // to the process.  
  15. var args = ["argument1""argument2"];  
  16. process.run(false, args, args.length); 
如:var arguments = ["-h","10.20.65.41","-p","5901","-w","11111111","--title","1111"];


积累:
  1. var WSS = new ActiveXObject("WScript.Shell");  
  2. 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进行打印

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值