1

I want to run a batch file which is on my local system using javascript or jquery. ActiveXObject didn't helped me at all. I know it is deprecated, but my system will be in some secured internal network.

  • 2
    How should the browser access a batch file on the local harddrive? All browsers should keep you from doing that through their sandboxes – Nico Haase Aug 07 '18 at 12:37
  • 2
    Why exactly didn't ActiveXObject help you? Do you have to run it in Chrome / Firefox etc or just IE? Short answer: besides using ActiveX you can't access the local filesystem via JavaScript using a Webbrowser – r3dst0rm Aug 07 '18 at 12:37
  • @NicoHaase I am displaying some data in browser and doing some processing saving it to my db and then I need to pass that data to a standalone desktop and have to open it in that Desktop application, for which I have written a BAT file. How can I achieve this. – zzed pathan Aug 07 '18 at 12:51
  • @r3dst0rm Yes I am using chrome. – zzed pathan Aug 07 '18 at 12:51
  • @zzedpathan Chrome won't support ActiveX, as it's only working in Internet Explorer. Therefore it's simply impossible as JavaScript engines are running in a sandbox. If you do some processing e.g. in Excel, you could prompt the user for a download in order to open the desired file. – r3dst0rm Aug 07 '18 at 13:42
  • You should use in your case HTA with javascript to execute the batch file in local – Hackoo Aug 08 '18 at 00:27
  • Check this ==> https://stackoverflow.com/questions/36104713/how-to-run-exe-file-or-bat-file-based-on-button-click-event-using-javascript?answertab=active#tab-top – Hackoo Aug 08 '18 at 00:37
  • @Hackoo Thanks man, but I am using Chrome so ActiveXObject isn't helping me. But now I am triggering a java function from browser to achieve the same. – zzed pathan Aug 08 '18 at 05:18

1 Answers1

0

We shouldn't be running any exec or batch file from browser. It is totally deprecated and also browser's are not given the access to OS threads. The best approach to achieve it is to trigger a method in backend (java or C#) and to achieve the same from that method.