How to run .exe file or .bat file based on button click event using Javascript
<p>In my current project, I would like to run .bat or .exe file using button click event using JavaScript. The content of batch file is as shown below:</p>

<pre><code>start "S:\" TemperatureSensor.exe
</code></pre>

<p>which start TemperatureSensor.exe file when TemperatureSensor button is clicked.
Code for HTML page is shown below:</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;body&gt;

&lt;p&gt;Click the button to make a BUTTON element with text.&lt;/p&gt;

&lt;button onclick="window.open('file:///S:/Test.bat')"&gt;Temperature Sensor&lt;/button&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>When I clicked on Temperature Sensor button, it should run Test.bat file but it just display following in new page:</p>

<p><a href="https://i.stack.imgur.com/Mv8zL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Mv8zL.png" alt="enter image description here"></a> </p>

<p>Am I missing ?? Is it possible to run .exe file using button click event??</p>

<p><strong>Updated:</strong>
Code for HTML page is shown below: </p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;body&gt;

&lt;p&gt;Click the button to make a BUTTON element with text.&lt;/p&gt;

&lt;button onclick="myFunction()"&gt;Temperature Sensor&lt;/button&gt;

&lt;script&gt;
function myFunction() {
      var oShell = new ActiveXObject("Shell.Application");

var commandtoRun = "C:\\TemperatureSensor.exe";
if (inputparms != "") {
var commandParms = document.Form1.filename.value;
 }

 // Invoke the execute method.  
 oShell.ShellExecute(commandtoRun, commandParms, "", "open", "1");
 }
 &lt;/script&gt;

 &lt;/body&gt;
 &lt;/html&gt;
</code></pre>

<p>When I clicked on Temperature Sensor button it displays error: <strong>Uncaught ReferenceError: ActiveXObject is not defined</strong>.</p>