Open .exe file by javascript

Hi Guys,

I am trying to open .exe file by javascript but not working with me!


    <script language="JavaScript" type="text/javascript">  
     MyObject = new ActiveXObject( "WScript.Shell" )  
     function RunExe()   
    }  0
       <h1>Run a Program</h1> 
      This script launch the file any Exe File<p> 
      <button onclick="RunExe()">Run Exe File</button> 

but the application didn’t launched! what is the problem here?

Thanks for all

See if this helps.

If it does not, try searching “launch .exe with JavaScript” or something like that.

1 Like

Also, what browser are you using? ActiveXObject is not defined in browsers other than IE. Not even Edge uses it.

Scripts like this won’t work anyhwere but while being run as file:// protocol accessors, and telling a script to run a file protocol seems incorrect, shouldn’t you just tell it to run the path?

1 Like

Yes you are right! that is what I noticed later…because only IE work with ActiveXObject …not like chrome and firefox!

But what I am looking for is for example open Microsoft virtual keyboard, open skype and so on through javascript. Is this possible?

I want to use chrome!

I think it would be better to simply place shortcuts for the apps on your desktop so you can open them quickly.

The security risks of giving scripts within a browser access to the underlying OS are great and are either extremely limited or not allowed at all.

Writing a Chrome extension could allow more than would be possible with JavaScript alone, but even then I don’t think opening and running OS exe files is something that is possible.

I’m… pretty sure Extensions fall under the same limitations and security zone concerns as script files. I could be wrong.

Though, if we’re at the point of local execution, why not instead take the opportunity to learn something like node.js, which does have the ability to execute local commands.

1 Like

Pretty much yes. They can provide ways to work with browser chrome, context menu, toolbars, tabs, panels, etc. (i.e. browser “stuff”) But when it comes to getting at the OS, other than maybe the clipboard, it’s a no go.

I tried this also didn’t work:

    <script src=""></script>
     <script language="JavaScript" type="text/javascript"> var $jQuery = jQuery.noConflict(); </script>

     <script type="text/javascript">
     jQuery("#example_link").on("click", function (event) 
       event.preventDefault(); // Recommended to stop the link from doing anything else
       document.dispatchEvent(new CustomEvent('funcIntraLaunch',
          'detail': { task: 'run',
                   program: 'C:\\Windows\\notepad.exe',
             workingfolder: '',
                  switches: '%MY_DOCUMENTS%\\switch.txt',
               windowstate: 'max',
                 recallapp: '',
                   options: '',
                       log: '',
                 playsound: '',
                showerrors: 'true'
                    } })); 

           <a href="#" id="example_link">Click me</a>

I got it…it works now … I have to install IntraLaunch extension in chrome.

That was a suggested search string?

You might not have taken into account that modern web browsers have tightened up on security weaknesses.

I tried this linke:

with intraLaunch extension and works!

1 Like

Yeah I know :wink:
But I mentioned as reply :shifty:

1 Like

This is my experience with this case if anyone want to solve like this scenario in simple way:

First to execute .exe files in OS in windows like “Notepad, cmd, calcs…etc” it’s impossible to do it in Chrome and firefox without plugins because security issue. In IE you can activate ActiveX to do it but will still always ask you to execute or not every time you refresh the page.

If you want to make it in Chrome you can use IE tab extension which will allows you to access IE option through opening new tab specialized for IE.

the script like this:

   <script type="text/javascript">
      function myFunction(){
         WshShell = new ActiveXObject("Wscript.Shell"); //Create WScript Object"C://Windows/cmd.exe"); // Please change the path and file name with your relevant 
        available path in client system. This code can be used to execute .exe file as well
         <H1>Example Running Command File from Browser Client Site Using Java Script</H1>
                  Clicking a button executes a Batch file
         <INPUT TYPE=Button Name=btn Value="Test Java Script" onClick="myFunction()">

Lastly many thanks for Guys in this great forum which I learned a lot from them :wink:

You can also register a URI protocol like myapp:// and just use a hyperlink to it. Works in any browser without any plugins or activex

1 Like

Hmmmm…Nice try…I will try it buddy! Thanks:rofl:

Any example can share it :biggrin:


Why would would you want to do this to someone visiting your site unless you want to infest their computer with malicious software?

1 Like