1

I'm using EXE files for the back end of an in-house website. I have server 2019 and IIS 10. When I call the EXE file IIS tries to download the file instead of executing it.

I'm calling like this:

             $.ajax({    
                    url: "cgi-bin/compPack.exe",    
                    dataType: "json",
                    type: "post",       
                    data: dataString,
                    error: ajaxError,           
                    success: function(json){   

Which gives an error because it's expecting a JSON string, and if I enter

sandbox/cgi-bin/myProgram.exe

in the browser it just downloads the EXE.

I've added the CGI module, set permissions on the CGI-BIN folder, tried adding and and removing .exe from Mime types as application/octet-stream but can't get it to run the binary file.

I'm not sure what I need to do to make it execute (any) EXE file in the cgi-bin folder.

Shawn
  • 3,031
  • 4
  • 26
  • 53
  • I suppose you mean executed on the client side? Automatically running an exe is a browser setting, and its a very insecure one. You can't configure this from the IIS side, otherwise everyone would be delivering viruses this way. – Nick.Mc Feb 13 '20 at 23:05
  • I mean I'm using an EXE file instead of say, a PHP script. The EXE tries to download instead of run. We have a 2012 server with IIS that runs them all day, so I know it can be done but I didn't set that up. – Shawn Feb 13 '20 at 23:09
  • A PHP script is evaluated on the web server and emits HTML. Is that what your EXE does? – Nick.Mc Feb 13 '20 at 23:10
  • It returns JSON , not HTML, but yes. – Shawn Feb 13 '20 at 23:13
  • 1
    Does the EXE responds to GET requests etc.?. I'm no expert but I beleive you have to register a custom handler and redirect all requests to it. Here's some links which are not too helpful but may put you on the right track. https://learn.microsoft.com/en-us/iis/configuration/system.webserver/handlers/ https://stackoverflow.com/questions/44978576/how-to-create-and-add-custom-httphandler-to-existing-iis-website – Nick.Mc Feb 13 '20 at 23:16
  • The standard way to write a web API that returns JSON is to just write one in ASP.Net (or your favourite language) and use an existing handler. – Nick.Mc Feb 13 '20 at 23:18
  • It does respond to GET/POST, returns headers, all the stuff you'd expect. There are libraries of EXE/CGI stuff to do that. I'm just missing some setting. – Shawn Feb 13 '20 at 23:20
  • maybe here is what I need https://www.ibm.com/support/knowledgecenter/en/SS8NLW_11.0.0/com.ibm.swg.im.infosphere.dataexpl.install.doc/t_velocity-cgi-modules-IIS.html – Shawn Feb 13 '20 at 23:27
  • That looks pretty promsing. – Nick.Mc Feb 13 '20 at 23:43
  • Do you mean you want to call an exe file in from the IIS and return the json result to the client side? Why you not directly call the exe file in the server by codes in your web application and return the json file to the client side? – Brando Zhang Feb 14 '20 at 02:02
  • that's exactly what I'm trying to do... IIS won't let me. I have a setting wrong somewhere. – Shawn Feb 14 '20 at 11:40

1 Answers1

0

The fix was to apply the settings as demonstrated here by IBM. Their Watson Explorer Engine also uses EXE's for it's CGI back end.

IIS 7.0 and higher on Windows 2008 and later systems:
Open IIS Manager:
For Windows 2008 systems: Select Control Panel > Administrative Tools > Internet Information Services (IIS) Manager.
For Windows 2012 systems: From the desktop, hover your cursor in the upper- or lower- right corner of the screen to show the charms. Click the Start charm, and then click the Internet Information Services (IIS) Manager tile.
In the Connections pane, expand the entry for your computer system, expand Sites, and select the default site, which is the site in which the Watson Explorer Engine virtual directory (vivisimo) is created.
Double-click the Handler Mappings feature.
If the state of CGI-exe is Enabled, no additional configuration is necessary. Proceed to Completing the Installation Process (All Platforms).
If the state of CGI-exe is Disabled, select it and click Edit Feature Permissions from the Actions pane. The Edit Feature Permissions window displays.
Select Execute and click OK to enable applications with the .exe extension to execute in response to CGI requests. If Execute is disabled, select Script > Execute, and then click OK.
Shawn
  • 3,031
  • 4
  • 26
  • 53