How can I run a local Windows Application and have the output be piped into the Browser

14,364

Solution 1

  1. Have the executable listen on a port following the HTTP protocol.
  2. Then have the web page make AJAX-style HTTP requests to the local port with JAvascript.
  3. The executable returns text.
  4. The web page updates itself through DOM manipulation in Javascript.

Yes, this works. It is happening 5 feet away from me right now in another cubicle.

Solution 2

Your already using WScript to launch, it can also read StdOut.

<html>
<head>
<script type="text/javascript">
function foo() {
 var WshShell = new ActiveXObject("WScript.Shell");
 var oExec = WshShell.Exec("ipconfig.exe");
 var input = "";

 while (!oExec.StdOut.AtEndOfStream) {
         input += oExec.StdOut.ReadLine() + "<br />";
 }

 if (input)
  document.getElementById("plop").innerHTML = input;
}
</script>
</head>
<body onload="foo();">
 <code id="plop"></code>
</body>
</html>

Solution 3

This is called CGI

Share:
14,364
Admin
Author by

Admin

Updated on June 22, 2022

Comments

  • Admin
    Admin almost 2 years

    I have Windows Application (.EXE file is written in C and built with MS-Visual Studio), that outputs ASCII text to stdout. I’m looking to enhance the ASCII text to include limited HTML with a few links. I’d like to invoke this application (.EXE File) and take the output of that application and pipe it into a Browser. This is not a one time thing, each new web page would be another run of the Local Application!

    The HTML/java-script application below has worked for me to execute the application, but the output has gone into a DOS Box windows and not to pipe it into the Browser. I’d like to update this HTML Application to enable the Browser to capture that text (that is enhanced with HTML) and display it with the browser.

    <body>
     <script>
     function go() {
       w = new ActiveXObject("WScript.Shell");
       w.run('C:/DL/Browser/mk_html.exe');
       return true;
       }
    
     </script>
    
     <form>
       Run My Application (Window with explorer only)
         <input type="button" value="Go" 
         onClick="return go()">
    </FORM>
    
    </body>