Link to home
Start Free TrialLog in
Avatar of Mike Broderick
Mike BroderickFlag for United States of America

asked on

IIS 6.0 How to define an Application Extension Mapping for an executable (exe)

I have Windows 2003 Server with IIS 6.0. I want to write SSI cgi #execs in shtml pages. I have been able to make one work, but I had to specify my program as the executable for the .exe mapping. This doesnt seem right. What if I want to write more that one exe on a web site:
        <p>Output from cgi: <!--#exec cgi="/cgi-bin/T1.exe" --></p>
        <p>Output from cgi: <!--#exec cgi="/cgi-bin/T2.exe" --></p>
Is there an interpreter (i.e cmd.exe) that I need to specify as the executable for the .exe mapping?
SOLUTION
Avatar of meverest
meverest
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mike Broderick

ASKER

OK, thanks. I added a new extension called .exe, and added T1,exe and T2.exe, and made sure it was set to allowed.
When I do this and load the test page, I get:

Output from cgi: Unhandled Exception: System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

For testing, my test page has 2 ssi execs, one with t1.exe and the other with t2.exe. One program should output  Hello, World, the other Hello, World 2. Instead, I get the above error twice, each after about a 20 second delay.

When I leave the mapping in (.exe --> T1.exe), it prints out t1.exe's output correctly, even when I specify #exec cgi="t2.exe" in my webpage.

Any ideas?
are these executables cgi compliant?  (i.e. do they get input variables from ENV and output to stdio?)

Cheers.
Yes (Currently they get no env variables but they put to stdout). The test pgms are maddeningly simple:

    Function Main(ByVal args As String()) As Integer
        Console.WriteLine("Content-type: text/html")
        Console.WriteLine("")
        Console.WriteLine("Hello, world!")
        Return 0
    End Function
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
When I run it i get the same error:

Unhandled Exception: System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

Just for grins, I added a Mapping (Home dir, configure...) to map .exe to T1.exe. It worked. However, if I specify //localhost/cgi-bin/t2.exe, it runs t1.exe, per the mapping. The point is, no parm errors.

Hello,

OK, so the mapping is doing exactly what I expected - running the script mapped interpreter with the actual access file as data.  From that behaviour, I assume that the file is not passed as stdin argument, but made available by some other mechanism.

This could be a permissions access thing, since the script map will run under a different user (worker process) as the  executable (anonymous user)

Try (temporarily) setting your anonymous user to administrator to see whether than makes any difference.

Cheers.
I added Administrators to IUSR_<myserver>. Same error.

I wonder if we need to specify an interpreter in the mappings. I actually tried a few, the same for the asp extension. Didnt work. I also tried to put cmd.exe in. I get a 404 error:
Failed to execute script: Http Status Code = 404

What a minute.  Have you setup 'Application Mapping' in IIS Application settings for your SHTML files?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes, shtm and shtml are mapped to ssinc.dll (the sys came that way).

I apologize about the mappings. I brought it up for three reasons:
 - Its nice to see something sort of work after banging your head against the wall
 - it shows me that the program is probably written properly and permissions to it are ok
 - I read somewhere that to make a bat file run as a cgi, you specify cmd in the mappings. Since
   cmd.exe can start both a bat file and an exe at the command line, and since all of the other extensions
   specify some sort of interpreter, it makes sense to try a mappng.
I  understand that mappings is not the way to set this up. I do thank you for you time in this, it is really frustrating that something so simple as an ssi exec is this diffucult to set up on the windows platform.
Sorry, I forgot to mention: I changed the annonomous user to the administrator. Same error.
I changed the mime map to make .exe text/html (it was application/octet-stream). Same error,
>>  - Its nice to see something sort of work after banging your head against the wall

yes, but it's really more like "a little bit dead" - it doesn't work at all in reality ;-)

>>  - it shows me that the program is probably written properly and permissions to it are ok

not necessarily - as a script mapping, it takes on different security (application pool) than executable (web server context)

>>  - I read somewhere that to make a bat file run as a cgi, you specify cmd in the mappings. Since
   cmd.exe can start both a bat file and an exe at the command line, and since all of the other extensions
   specify some sort of interpreter, it makes sense to try a mappng.

but an executable runs natively - it doesn't need an interpreter.

>> it is really frustrating that something so simple as an ssi exec is this diffucult to set up on the windows platform.

beleive it or not, it *is* simple.  You only need the steps that I have described earlier on.  If it still doesn't work, then you may have screwed something up along the way from all that trial-and-error.  If you can, try it on a fresh install (if you have one available) to prove that to yourself.

Cheers.
We have a W/2000 server we use to store backups and nothing else. Set it up there. Worked the first time.

There was no node to to define web service extensions. I dont know the level of IIS. I assume 5.0 or earlier.

My development sys has iis 5.1. It is not "fresh" (I monkey with it all the time) but I will try it on that system also.

Thanks so far.
When I try to run the ssi exec on my dev computer, I get what looks like a dump of my program itself:
HTTP/1.1 200 OK Server: Microsoft-IIS/5.1 Date: Thu, 07 Feb 2008 17:04:15 GMT X-Powered-By: ASP.NET Connection: close X-AspNet-Version: 2.0.50727 Accept-Ranges: bytes Cache-Control: public Expires: Fri, 08 Feb 2008 16:45:50 GMT Last-Modified: Tue, 05 Feb 2008 17:25:39 GMT ETag: "1C8681C2047AB80:1C869A8E557E3E1" Content-Type: application/octet-stream Content-Length: 24576 MZÿÿ¸@¬º´ Í!¸LÍ!This program cannot be run in DOS mode...
> This program cannot be run in DOS mode..
I guess this error message does not need any further explantions.
I opened a case with Microsoft. They had me run the following command on the server:
    caspol -s off
It worked (my page displayed hello world generated from my SSI CGI).

However, this turns off Code Access Security. First, it is temporary. When you press the enter key it is turned back on and my CGI doesnt work. Second, CAS is turned off for the whole machine. I do not know enough about CAS to feel comfortable turning it off for the whole machine.

I have tried (with MS support's help) to use the Framework config tool (I had to install the 600 meg SDK, thank you MS) to set up a machine code group and give it full permissions. We specified URL, my directory/*. No luck. MS duplicated the problem and is currently researching.

If somebody can tell me how to set the Framework 2.0 config tool to allow my CGI to execute, please direct me.

Thanks
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial