1

I've got a Problem here trying to open some Batch-Scripts from a HTML-Page. So, step by step the Situation looks like this:

In our company we have a program with a GUI running on Windows. This Program has an "HTML-Viewer", which is just a kind of enbedded MS IE (I assume it is linked to the localy installed IE). While using this program, we need to execute some commands on the Windows Command Prompt. To make it easier and safer, we already saved the commands in Batch-Files on the computers (locally). Now, to make it more easy, we would like, to start this commands/batch-scripts from a localy saved html page via the HTML-Viewer in the program.

Because of the HTML-Viewer it is not possible to use an HTA-Application (with ActiveX) (which I tried, and which runs perfectly...but started from the Desktop) (and what was proposed in several similar questions here, I already found)

So I think, I need a kind of layer between HTML and Batch, something i can run with a HTML page and is going to start Batch script:

HTML -> XXX -> Batch

I tried php, which of course failed because everything is local.

I tried javascrip, wich of course failed because js does not have the ability to make system calls.

perl won't do it either...

So tu sum up: I would need an command in HTML, that can start an batch-script (or a command in the windows prombt)?!

CallMeTom
  • 125
  • 7

1 Answers1

0

You can use the download attribute in the a tag to download the file that you want. Here's an example:

<a href="C:\User\Bob\Desktop\yourFolder\file.bat" download> Open .bat file</a>

For safety reasons, you cannot open up a batch file directly; the user has to go through a process before actually running the file.

Learn more about the download attribute here

Gerhard
  • 22,678
  • 7
  • 27
  • 43
MattGotJava
  • 185
  • 3
  • 14
  • 1
    You have a missing quote at end of `file.bat` – Aacini Dec 01 '17 at 14:09
  • Thanks for noticing that mistake. I should have triple checked it!! – MattGotJava Dec 01 '17 at 19:28
  • The files are already on the computers, so we do not need to download them (or am i missunderstandig the idea?). The security reasons on the other hand is blocking the whole html-think :-( – CallMeTom Dec 04 '17 at 10:10
  • If you don't need to download it, do you need to open it? Check [here](https://stackoverflow.com/questions/18980957/is-it-possible-to-run-an-exe-or-bat-file-on-onclick-in-html) to learn more about opening files. – MattGotJava Dec 05 '17 at 03:12
  • I hope that I was able to help you! If it *does* work, please click the green check mark under the voting number so that others can see that this question already has an answer. – MattGotJava Dec 05 '17 at 03:14
  • Thanks, the link helped... The problem was: to test my scripts I tried to open the HTML-Pages with FireFox (my default Internet Browser). This resulted in actually opening the script (like in: see whats written inside). As written in the thrend you linked, opening it with IE (or the HTML viewer of our programm) results in executing the script! Thanks – CallMeTom Dec 05 '17 at 09:39