Run .exe on a Webpage using Firefox

As I have showed in my earlier post How to run .exe on a Webpage but that code runs only on Internet Explorer.

Here after the demand of my readers I am going to show you how can you achieve this task through firefox browser.

 

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

In the above code you can clearly see that in “href” attribute I am calling a user-defined function  LaunchApp() and functionality of this function is shown as follows:

<script>
function LaunchApp() {
    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>

In the above code you can see the use of JavaScript privileges API. You can add one line of code asking permission to enable a privilege that can allow your script to access your target.

In Mozilla Firefox there are certain privileges that are associated with specific targets, In our code we are using “UniversalXPConnect” privilege to give Unrestricted access to browser APIs using XPConnect.

After assigning privileges just running your local .EXE file by using Mozilla Firefox built in classes.

That’s it just use above code and do let me know your experience about it through comments.

Tagged: , , , , ,
  • Pingback: 如何使用網頁 執行 .exe 檔 - Firefox、IE - 2012 | Tsung's Blog

  • Irwingretczko

    Can I run an EXE located on the website???

    • SyedAsadAhmed

      Hey Irwingretczko:

      You can execute “.exe” located on your webserver.

      Cheers

  • http://twitter.com/StijnAa stijn

    is de exe runing on my site or on my pc ??

    • http://codereflex.net Syed Asad Ahmed

      hi stijn:

      can you send your error message?

  • Aslam Memon

    how can i make it run across browsers?? pls help asap

    • SyedAsadAhmed

      Aslam:
      Check for the browser first and then execute your code according to browser return value.This can be done through javascript easily.

  • http://www.techflashed.com/ Tech Flashed

    This script is not working

  • Murasoli Selvan

    Its not working for me in FF, But IE version of code works perfectly, Can i know if anything needs to be changed for webrtc related exe to be executed.

  • RFoster

    UniversalXPConnect is no longer available in FF 17+. Does anyone here know of an extension or other workaround for FF?