Open .exe file by javascript


#3

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?


#4

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?


#5

I want to use chrome!


#6

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.


#7

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.


#8

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.


#9

I tried this also didn’t work:

   <html>
    <script src="https://code.jquery.com/jquery-2.2.3.min.js"></script>
     <script language="JavaScript" type="text/javascript"> var $jQuery = jQuery.noConflict(); </script>

     <script type="text/javascript">
 jQuery(document).ready(function()
 {
     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: 'http://www.yourdomain.com/sound.wav',
                showerrors: 'true'
                    } })); 
                      });
            });
       </script>

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

#10

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


#11

That was a suggested search string?


#12

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


#13

I tried this linke: http://www.particlesoftware.com/examples/simple_single_object.html

with intraLaunch extension and works!


#14

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


#15

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:

   <HTML><HEAD>
   <script type="text/javascript">
      function myFunction(){
         WshShell = new ActiveXObject("Wscript.Shell"); //Create WScript Object
        WshShell.run("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
       }
        </SCRIPT>
      </HEAD>
       <BODY>
         <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()">
        </BODY>
            </HTML>

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


#16

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


#17

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


#18

Any example can share it :biggrin:


#19

Try https://stackoverflow.com/questions/80650/how-do-i-register-a-custom-url-protocol-in-windows


#20

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


#21

you are completely right…but in my project will not be in public…it’s local and for special case just!


#22

Then do an OS app and include a browser inside the app in it’s own thread. That will allow you to drag n drop, copy and paste to your hearts content.
You should never seek to defeat internet security features.