.EXE Files not behaving correctly on IIS6 Windows 2003 Server

Chris Kenward
Chris Kenward used Ask the Experts™
on
Hi Folks

I have an interesting situation that has suddenly become urgent as I have a customer who is about to take his website away unless I can fix this issue.

Server: Windows 2003 installed with all updates including all .NET updates
Web: IIS 6

There are a large number of websites on this server, all working fine. However, several of them have .exe files resident in various folders and have been put there by our customer because they want people to be able to download or run them by clicking a link on the website.

Of all websites that contain downloadable files, only one is working and that is a website designed only in HTML. The site in particular where I'm trying to help my customer is coded with .NET 4 in mind. The .exe file is a valid file and is in the right place but, if one clicks on the link to the file, instead of getting a prompt which says "Do you want to Save or Run this file?" the web user gets a 404 Page not found error.

Has anyone come across this before? Would certainly appreciate the help getting it sorted.

Cheers
Chris
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
If it is in a working directory, the problem is usually permissions.  Check the IIS and Windows permissions and make sure that 'IUSR_xxx' can access the file.  You could add 'Everyone' also.
Chris KenwardIT Tech Support

Author

Commented:
Hi DaveBaldwin

I've checked the permissions on the folders of both the one I mentioned that does work and the one that doesn't. They are identical. The IIS_USR has read and execute permissions on all folders under the website root. I'm reluctant to give the user EVERYONE any permissions on these folders as the server is a multi-website server.

Cheers
Chris
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
I meant to check the file permissions.  They can be different than the folder permissions.
Chris KenwardIT Tech Support

Author

Commented:
Hi Dave

Permissions on files are all inherited from parent. I've double-checked the permissions and they are all set to Read & Execute, Read etc.

Thanks
Chris
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
Chris, something is different because IIS is giving you a 404.  Did you check file permissions in both Windows and IIS?  Any chance the URL and the filename are not a perfect match?  Does the filename have spaces in it that are converted to '%20'?  Does the problem occur in all browsers?
Chris KenwardIT Tech Support

Author

Commented:
Hi again, Dave

Thanks for persevering with me! :)

OK - have been off and checked the permissions in IIS and all the same as Explorer. No spaces in the filename. URL and file are a match. Problem occurs in all browsers.

If I had hair I'd be pulling it out at this point! lol

Cheers
Chris
Chris KenwardIT Tech Support

Author

Commented:
Dave, a quick question if I may - would it depend on what the file was trying to do? For example, I think this specific file is an installer in .exe format.
Top Expert 2016

Commented:
I hate to point out the obvious but is the hyperlink correct?

compare the hyperlink given by the webpage to the actual location of the file. The actual folder should not have the execute privilege just the read permission

any url rewrite rules in effect?
Chris KenwardIT Tech Support

Author

Commented:
Hi ve3ofa

The hyperlink is 100% correct. The location of the file is right and I've checked it's there and available. There are no rewrite rules in operation, no.

Cheers
Chris

Commented:
This issue can happen with IIS in cases where  the file has a file name extension that is not a defined MIME type on the Web server.In your case it is .exe

You can try the following steps

To define a MIME type for a specific extension, follow these steps: 1.Open the IIS Microsoft Management Console (MMC), right-click the local computer name, and then click Properties.
2.Click MIME Types.
3.Click New.
4.In the Extension box, type the file name extension that you want (for example, .exe).
5.In the MIME Type box, type application/octet-stream.
6.Apply the new settings. Note that you must restart the World Wide Web Publishing Service or wait for the worker process to recycle for the changes to take effect. In this example, IIS now serves files with the .exe extension.
Chris KenwardIT Tech Support

Author

Commented:
Hi there, ssujai

Thanks for your response. I've had a look at that and it appears to be installed. Herewith a screenshot of the mime types setup on the web server.

Cheers
Chris

Screenshot - MIME types

Commented:
Can you check the web service extensions in IIS mmc. Since you are using .net4, set that to allowed and see if it works
Top Expert 2011

Commented:
Guys,

You simply need to allow All unknown CGI Extensions from the server's web service extensions. This may required IISRESET

Alternatively, you can allow only those exe file paths that you would need to allow to download.

Regards,
Sanjay Santoki
Chris KenwardIT Tech Support

Author

Commented:
Hi sanjsantoki

This sounds good! OK - I've had a look at the server and attempted to add the file as a web service extension all on its own. I get an error (see image below) and it won't allow me to add the file.

I don't think from a security point of view it would be good to open all unknown CGI so would be great if we could just select specific .exe files.

Best wishes
Chris
Error screenshot
Top Expert 2011
Commented:
Chris,

Generally, IIS will do one of three actions given a URL (such as
http://server/downloads/app.exe )
1. Treat app.exe as a file resource and allow the static file handler to
download it
2. Treat app.exe as a script resource, which means the resource is given to
a Script Engine (defined by the Application mapping for the extension),
which does some processing on the resource to generate content to return to
the client.
3. Treat app.exe as an executable resource on the server and execute it on
the server to generate content to return to the client

These three actions directly correlate to the setting of the "Execute
Permissions" on the URL.

You want users to be able to click the link to SAVE the target file -- this
means that you want to configure IIS to treat app.exe like #1. This means
that the virtual directory MUST have "Execute Permissions" set to "None" or
"Scripts" in order to allow .exe to be downloadable. This is how Execute
permission map to my description above:
Execute Permission: None == #1
Execute Permission: Scripts == #2
Execute Permission: Scripts and Executables == #3

You can actually diagnose your problem by simply looking at the IIS web log
files. The access to .exe file probably has 404 2 1260 while the access to
..bat file probably has 404 3 50. Those are the classic security denied
reasons.


So, how I would describe your situation is:
1. Regarding the inability to download .exe files -- your problem is that
you have Execute Permissions on the virtual directory set to "Scripts and
Executables", which causes IIS to try to execute the .exe on the server --
which is NOT what you wanted to do. And since IIS tries to execute the .exe
on the server and it is not enabled in Web Service Extensions, you get a 404
2 1260. No amount of MIME Type configuration will help -- you did not
configure IIS to download the resource, so MIME Type isn't even in the
picture and no amount of read/execute permissions is going to help.

2. Regarding the inability to download .bat files -- your problem is that
..bat is NOT in the MIME Type by default, and there is also no Application
mapping for the .bat extension -- hence IIS tries to serve it as a download
but fails due to missing MIME Type and results in 404 3 50.

Regards,
Sanjay Santoki

Commented:
What happens when you set the execute permissions in the home directory settings to 'none'
Chris KenwardIT Tech Support

Author

Commented:
@sanjsantoki
Hi Sanjay - I have followed your instructions and it appears right now that the file immediately begins to download. I've changed the home directory settings to "Scripts only".

@ssujai
It appears that Sanjay might have given me the solution. Thanks for your input though.

Cheers
Chris
Top Expert 2011

Commented:
Kenwardc,

Glad to here that my suggestion worked for you. Do not forgot to accept the solution if worked for you.

Regards,
Sanjay Santoki
Chris KenwardIT Tech Support

Author

Commented:
Brilliantly detailed solution. Thank you so much! Definitely adding this one to the knowledge base.

Thanks to all who responded.

Chris

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial