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:
start "S:\" TemperatureSensor.exe
which start TemperatureSensor.exe file when TemperatureSensor button is clicked. Code for HTML page is shown below:
<!DOCTYPE html>
<html>
<body>
<p>Click the button to make a BUTTON element with text.</p>
<button onclick="window.open('file:///S:/Test.bat')">Temperature Sensor</button>
</body>
</html>
When I clicked on Temperature Sensor button, it should run Test.bat file but it just display following in new page:
Am I missing ?? Is it possible to run .exe file using button click event??
Updated: Code for HTML page is shown below:
<!DOCTYPE html>
<html>
<body>
<p>Click the button to make a BUTTON element with text.</p>
<button onclick="myFunction()">Temperature Sensor</button>
<script>
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");
}
</script>
</body>
</html>
When I clicked on Temperature Sensor button it displays error: Uncaught ReferenceError: ActiveXObject is not defined.