You are currently offline, waiting for your internet to reconnect

Listing the Default IIS MIME Map Settings Using WSH

Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
Summary
This article describes how to create a Windows Scripting Host (WSH) script to list the default Multipurpose Internet Mail Extensions (MIME) Map settings for a server running Microsoft Internet Information Services (IIS).
More information
Multipurpose Internet Mail Extensions (MIME) is a way of configuring browsers or mail clients to view files that are in multiple formats based on a MIME Type. MIME Mapping is a process by which IIS maps files by their extensions to a particular MIME Type. For example, a file with a .htm extension has a MIME Type of "text/html," whereas a file with a .gif extension has a MIME Type of "image/gif."

When a request is made by a client for a particular file, IIS uses the MIME Map to determine the correct MIME Type that the client will be receiving. IIS contains a large list of default MIME Types to use, and returns a MIME type of "application/octet-stream" for any file extension that is not explicitly mapped.

When Web administrators create or store new file formats with extensions that may be undefined, the following WSH code may help determine the contents of the default MIME Types list by displaying a sorted list of all current MIME Type definitions.

Listing the Default MIME Map

Copy the following WSH code and save it as Mimemaps.vbs:
Option ExplicitDim objMimeMapDim varMimeMapDim intMimeMapDim objDictionaryDim intCountConst dictKey  = 1Const dictItem = 2Set objDictionary = CreateObject("Scripting.Dictionary")Set objMimeMap = GetObject("IIS://localhost/mimemap")varMimeMap = objMimeMap.Get("MimeMap")If IsArray(varMimeMap) Then  For intCount = LBound(varMimeMap) To UBound(varMimeMap)    objDictionary.Add varMimeMap(intCount).Extension, varMimeMap(intCount).MimeType  Next  SortDictionary objDictionary,dictKey  intMimeMap = objDictionary.Count  WScript.Echo "Total MIME Map Entries: " & intMimeMap & vbCrLf  WScript.Echo "Extension" & vbTab & "MIME Type"  For Each varMimeMap in objDictionary    WScript.Echo varMimeMap & vbTab & objDictionary(varMimeMap)  NextEnd IfFunction SortDictionary(objDict,intSort)  Dim strDict()  Dim objKey  Dim strKey,strItem  Dim X,Y,Z  Z = objDict.Count  If Z > 1 Then    ReDim strDict(Z,2)    X = 0    For Each objKey In objDict        strDict(X,dictKey)  = CStr(objKey)        strDict(X,dictItem) = CStr(objDict(objKey))        X = X + 1    Next    For X = 0 to (Z - 2)      For Y = X to (Z - 1)        If StrComp(strDict(X,intSort),strDict(Y,intSort),vbTextCompare) > 0 Then            strKey  = strDict(X,dictKey)            strItem = strDict(X,dictItem)            strDict(X,dictKey)  = strDict(Y,dictKey)            strDict(X,dictItem) = strDict(Y,dictItem)            strDict(Y,dictKey)  = strKey            strDict(Y,dictItem) = strItem        End If      Next    Next    objDict.RemoveAll    For X = 0 to (Z - 1)      objDict.Add strDict(X,dictKey), strDict(X,dictItem)    Next  End IfEnd Function				

Run the WSH script from a command prompt using the following syntax:
CSCRIPT.EXE C:\MIMEMAPS.VBS | MORE
The output should be similar to the following:
Microsoft (R) Windows Script Host Version 5.1 for WindowsCopyright (C) Microsoft Corporation 1996-1999. All rights reserved.Total MIME Map Entries: 189Extension       MIME Type.*      application/octet-stream.323    text/h323.acx    application/internet-property-stream.ai     application/postscript.aif    audio/x-aiff.aifc   audio/aiff.aiff   audio/aiff.asf    video/x-ms-asf.asr    video/x-ms-asf.asx    video/x-ms-asf.au     audio/basic-- More  --				

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:
References
For more information on Microsoft's scripting technologies, see the Microsoft Developer Network web site at the following URL:
iis
Properties

Article ID: 246068 - Last Review: 06/19/2014 06:28:00 - Revision: 4.0

  • kbinfo KB246068
Feedback