0

I want to execute a batch file on a button click event from simple HTML page.

In IE, I can use ActiveXObject to achieve this however in other browser ActiveXObject is not supported.

Sample HTML File:

<html>
<head>
<title>Run Batch</title>
<HTA:APPLICATION
  APPLICATIONNAME="Run Batch"
  ID="MyHTMLapplication"
  VERSION="1.0"/>
</head>
<script type="text/javascript">

function RunBat(){

    var shell = new ActiveXObject("WScript.Shell");
    var path = "D:/Test.bat";
    shell.run(path);
}
</script>

</head>
<form>
Execute:
<input type="button" Value="Run" onClick="RunBat();"/>
</form>
</html>

I have gone through many questions on different forums and what I have found is that, in other browsers it is possible through some add-ons.

Is there any other way to execute it without using any add-ons in other browser?

If no, what are the add-ons I can use for Firefox, Chrome and Edge browsers to achieve this?

Lazar Nikolic
  • 2,798
  • 1
  • 14
  • 29
  • What does the batch script actually do? It might be a case that there is a better way to trigger it from all browsers if you can share that. – StudioTime Sep 16 '19 at 07:35
  • I understand you want it code in JavaScript, but don't you want it to code in PHP? – Shiz Sep 16 '19 at 07:40
  • Possible duplicate of [ActiveXObject in Firefox or Chrome (not IE!)](https://stackoverflow.com/questions/7022568/activexobject-in-firefox-or-chrome-not-ie) – A. Meshu Sep 16 '19 at 08:00
  • @DarrenSweeney - The batch script executes a set of java command. It compiles a java file and then run the class file. – Chandresh Parmar Sep 16 '19 at 11:45

0 Answers0