Executing a Windows Batch file via Button Click

I have Outsystems running over Java Stack. I am trying to create a web application where with a click of a button, I want to execute a .bat file which is present in my windows desktop. Is it possible to execute the bat file with any pre defined action? Or is it possible to execute the .bat file by calling a javascript action which gets executed by button click? Note: This is only being used by 2 or 3 users only, who would have the .bat file in their desktop (or in the C:\Windows\System32 folder)

Hi Somesh,

This is not possible. For security reasons, a web browser cannot run a file on the local computer. Imagine if that was possible, a malicious website could take over your computer!

Hi Somesh,

I think that whatever you are planning is not ideal! (because of all the Kilian said)

But if this was critical for the success of a project of mine I would probably try doing some ActiveX control, and even this would only work in Internet Explorer (even Edge won't run them).

Hope this helps!

Again, not ideal- but one solution:

Could you store the bat or a small exe as a resource in your application, and the button the user clicks would download it? Then all they would have to do is open the downloaded exe or bat to run (one or two extra clicks?)

Hi Somesh,

I have an idea!

Try following solution to execute bat file using ActiveX only on IE,

Its complicated to execute it in other browsers.

Just create a batch file and save in the location where your html file is there.

<a href="test.bat">TEST</a>

this anchor tag will execute the (test.bat) batch file. After clicking on the link <TEST>, you will get the window prompting to open/save/close, if you will click on open then batch file will be executed.


<script type="text/javascript">
function myFunction(){
   WshShell = new ActiveXObject("Wscript.Shell"); //Create WScript Object
   WshShell.run("d://temp/testJS.bat"); // 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

<input type="button" value="Test Java Script" onClick="myFunction()">

Hope It Helps!!