Skip to main content
Question

Add MIME Types Pragmatically

  • May 16, 2014
  • 2 replies
  • 21 views

Forum|alt.badge.img+3

I have been setting up multiple IIS servers for HTTP distribution points and was getting tired of manually changing the MIME types. Here is a super quick script for Windows Server with IIS7 to add the MIME types automatically:

cd %windir%system32inetsrv
rem Remove Existing MIME Types
appcmd set config /section:staticContent /-"[fileExtension='.dmg',mimeType='file/download']"
appcmd set config /section:staticContent /-"[fileExtension='.pkg',mimeType='application/octet-stream']"
appcmd set config /section:staticContent /-"[fileExtension='.mpkg',mimeType='application/vnd.apple.installer+xml']"
appcmd set config /section:staticContent /-"[fileExtension='.bom',mimeType='file/download']"
appcmd set config /section:staticContent /-"[fileExtension='.',mimeType='file/download']"
appcmd set config /section:staticContent /-"[fileExtension='.',mimeType='application/octet-stream']"
rem Add New MIME Types
appcmd set config /section:staticContent /"[fileExtension='.dmg',mimeType='file/download']"
appcmd set config /section:staticContent /
"[fileExtension='.pkg',mimeType='application/octet-stream']"
appcmd set config /section:staticContent /"[fileExtension='.mpkg',mimeType='application/vnd.apple.installer+xml']"
appcmd set config /section:staticContent /
"[fileExtension='.bom',mimeType='file/download']"
appcmd set config /section:staticContent /"[fileExtension='.
',mimeType='file/download']"
appcmd set config /section:staticContent /"[fileExtension='.',mimeType='application/octet-stream']"

2 replies

Forum|alt.badge.img+3
  • Author
  • New Contributor
  • June 10, 2014

So I have updated this a bit to be able to create the virtual directory and set the physical path credentials, I hope this helps someone else out. Make sure you change the DOMAINUSER and PASSWORD to your credentials needed for the setup.

cd %windir%system32inetsrv

rem Create Virtual Directory for CasperShare
AppCmd.exe ADD vdir /app.name:"Default Web Site/" /path:/CasperShare /physicalPath:S:CasperShare

rem Set the Physical Path Credentials for the Casper Read-Only User
Appcmd set vdir /vdir.name:"Default Web Site/CasperShare" /userName:"DOMAINUSER" /password:"PASSWORD"

rem Remove Existing MIME Types
appcmd set config /section:staticContent /-"[fileExtension='.dmg',mimeType='file/download']"
appcmd set config /section:staticContent /-"[fileExtension='.pkg',mimeType='application/octet-stream']"
appcmd set config /section:staticContent /-"[fileExtension='.mpkg',mimeType='application/vnd.apple.installer+xml']"
appcmd set config /section:staticContent /-"[fileExtension='.bom',mimeType='file/download']"
appcmd set config /section:staticContent /-"[fileExtension='.',mimeType='file/download']"
appcmd set config /section:staticContent /-"[fileExtension='.',mimeType='application/octet-stream']"
rem Add New MIME Types
appcmd set config /section:staticContent /"[fileExtension='.dmg',mimeType='file/download']"
appcmd set config /section:staticContent /
"[fileExtension='.pkg',mimeType='application/octet-stream']"
appcmd set config /section:staticContent /"[fileExtension='.mpkg',mimeType='application/vnd.apple.installer+xml']"
appcmd set config /section:staticContent /
"[fileExtension='.bom',mimeType='file/download']"
appcmd set config /section:staticContent /"[fileExtension='.
',mimeType='file/download']"
appcmd set config /section:staticContent /"[fileExtension='.',mimeType='application/octet-stream']"


Forum|alt.badge.img+7
  • Valued Contributor
  • January 31, 2017

Awesome, thanks for posting this! Very helpful.

Why do you need the entries with the fileExtension='.' ? I don't think we have been using those and have not noticed any issues.