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?
MikeBroderickAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

meverestCommented:
Hello,

there is no mapping for executable files.  In order to make it work, you need to:

a) make sure that the web interactive user (e.g. IUSR_<computername>) has appropriate read/execute rights to the executable and directory,
b) enable execute permissions to include 'scripts and executables' - web site properties->home directory->execute permissions
c) add a new 'web service extension' enabling the .exe file/s to run.

Cheers.
0
MikeBroderickAuthor Commented:
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?
0
meverestCommented:
are these executables cgi compliant?  (i.e. do they get input variables from ENV and output to stdio?)

Cheers.
0
The Five Tenets of the Most Secure Backup

Data loss can hit a business in any number of ways. In reality, companies should expect to lose data at some point. The challenge is having a plan to recover from such an event.

MikeBroderickAuthor Commented:
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
0
meverestCommented:
Hi,

I don't reckon that adding script maps will do you much good - it's not supposed to work like that.  What that does is when you try to access and exe, it will run the script map executable with the actual accessed file as an argument.  Perhaps that is what the error is telling you?

Do these executables work OK from the cmd shell?  Normally you will access them directly, like http://localhost/t1.exe

Cheers.
0
MikeBroderickAuthor Commented:
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.

0
meverestCommented:
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.
0
MikeBroderickAuthor Commented:
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

0
Ted BouskillSenior Software DeveloperCommented:
What a minute.  Have you setup 'Application Mapping' in IIS Application settings for your SHTML files?
0
meverestCommented:
>> I added Administrators to IUSR_<myserver>. Same error.

put administrator as the anonymous user - not just add IUSR to administrators group (IUSR may have deny restrcitions someplace)

>> I wonder if we need to specify an interpreter in the mappings.

no, no NO!  I said already that you do NOT need any mappings.  you MUST not use mappings - the cgi needs to run directly.

what about put a mime map in there for .exe - make it text/html

Cheers.
0
MikeBroderickAuthor Commented:
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.
0
MikeBroderickAuthor Commented:
Sorry, I forgot to mention: I changed the annonomous user to the administrator. Same error.
0
MikeBroderickAuthor Commented:
I changed the mime map to make .exe text/html (it was application/octet-stream). Same error,
0
meverestCommented:
>>  - 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.
0
MikeBroderickAuthor Commented:
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.
0
MikeBroderickAuthor Commented:
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...
0
ahoffmannCommented:
> This program cannot be run in DOS mode..
I guess this error message does not need any further explantions.
0
MikeBroderickAuthor Commented:
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
0
MikeBroderickAuthor Commented:
MS Support narrowed the problem down to the dotnet framework 2.0, and IE 7 installed on the server. Something about security and those two factors with IIS. They are opening a request to fix it in IE 8 and have refunded my money. They have also talked me into using another method to programatically insert stuff onto a web page (aspx).
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.