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?
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.
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.
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