INFO: Executing Files by Hyperlink and the File Download Dialog BoxID: Q232077
|
Many Web sites, particularly on corporate intranets, have hyperlinks to files that the user needs to execute on the local system. For obvious security reasons, Internet Explorer prevents any hyperlink action from automatically running any downloaded executable or other possibly dangerous files without displaying some form of dialog box prompt to the user.
In these situations, the File Download dialog box is not preventable in any way. This includes the use of HTML tags, script in the page, hosting the WebBrowser control, and changing security zone options.
Unfortunately, this dialog box can be disruptive to a Web-based interface that relies on these sorts of links to simplify the use of executable files stored on the Web server. This article discusses two alternative safe methods for automatically executing files by hyperlink.
Internet Explorer displays the File Download dialog box for two primary reasons: safety and choice. To be safe, the browser must never execute a potentially dangerous file on the user's system automatically without potential user intervention. Furthermore, Web sites have traditionally used links to executable files with two different intentions: the site intends for the user either to execute the linked file or to save it. Unfortunately, there is nothing in the HTML specification for the anchor tag (<A>) or any current scripting object model that provides a means for the Web site to indicate which is desired for a particular link. Thus, the burden of choice is on the user. The user must decide whether they want to run or save the file.
Internet Explorer decides whether to display the File Download dialog box primarily by checking the file's extension and looking in the registry for an application that reads that file. For most types of files, the user can clear the "Always ask before opening this type of file" option in the dialog box, which grants permission to Internet Explorer to not display the dialog box in the future for those specific file types. Users can also change this setting in the Edit File Types dialog box accessible from the shell's Folder Options by flipping the "Confirm open after download" check box.
However, Internet Explorer contains a predefined, hard-coded list of file extensions that it inherently distrusts. These extensions correspond to generic executables and other kinds of files that have the capability to harm the user's machine without the proper security safeguards. The File Download dialog box cannot be prevented for any files of these types. The "Always ask before opening" option will be grayed out on the dialog box and you won't be able to select it. Following is the list of the file extensions for these file types:
As a convention, this article refers to any of these types of files as "executable" files.EXE, COM, BAT, LNK, URL, CMD, INF, REG, ISP, BAS, PCD, MST, PIF, SCR, HLP, CHM, HTA, ASP, JS, JSE, VBS, VBE, WS, WSH
Click on the icon in the following window to run this very special
program automatically without annoying dialog boxes:
<IFRAME SRC="\\server\share\directory"></IFRAME>
Note that the HTML code points to the directory that the file is located in, not the file itself.
[version]
signature="$CHICAGO$"
AdvancedINF=2.0
[Add.Code]
file.zzz=file.zzz
[file.zzz]
clsid={15589FA1-C456-11CE-BF01-00AA0055595A}
FileVersion=1,0,0,0
hook=zzzinstaller
[zzzinstaller]
run=%EXTRACT_DIR%\file.zzz
Replace the instance of File.zzz above with the executable file to be run.
<HTML><HEAD><TITLE>Page of executable links</TITLE></HEAD>
<BODY>
<BR/>
<!-- hyperlink uses central script function called linkit() -->
<A HREF="" onclick="return linkit('signed-testfile.exe');">
SIGNED-CLOCK.EXE</A>
<SCRIPT>
// linkit puts filename into HTML content and spews it into iframe
function linkit(filename)
{
strpagestart = "<HTML><HEAD></HEAD><BODY><OBJECT CLASSID=" +
"'CLSID:15589FA1-C456-11CE-BF01-00AA0055595A' CODEBASE='";
strpageend = "'></OBJECT></BODY></HTML>";
runnerwin.document.open();
runnerwin.document.write(strpagestart + filename + strpageend);
window.status = "Done.";
return false; // stop hyperlink and stay on this page
}
</SCRIPT>
<!-- hidden iframe used for inserting html content -->
<IFRAME ID=runnerwin WIDTH=0 HEIGHT=0 SRC="about:blank"></IFRAME><BR/>
</BODY></HTML>
Additional query words:
Keywords : kbDHTML kbIE400 kbIE401 kbNavigation kbSecurity kbIE401sp1 kbIE401sp2 kbGrpInet kbIE500
Version : WINDOWS:4.0,4.01,4.01 SP1,4.01 SP2,5.0
Platform : WINDOWS
Issue type : kbinfo
Last Reviewed: June 15, 1999