We help IT Professionals succeed at work.

Script available to add MIME type and Documents?

3,254 Views
Last Modified: 2008-08-13
Hi Experts,

Is there a way to add MIME Types and Documents to IIS6.0 without using Internet Information Services Manager (IISM)? Im thinking there may be a script available or command line systax that I'm not aware of?

IIS 6.0 Windows 2003 SP1

Virtual Directory | Properties | Documents | Enable / Add default page

Virtual Directory | Properties | HTTP Headers | MIME Types | New

Thanks you for your advice,

Cheers, naexpert
Comment
Watch Question

Top Expert 2008
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Hi meverest,

I'll try this and give you feedback asap.

Thanks for your input.

Cheers, naexpert.

Author

Commented:
Hi meverest,

I tried your script and it works for MIME types, brilliant, part of my original question was also about how to add documents?

Virtual Directory | Properties | Documents | Enable / Add default page

If you can provide me with this info, then you've cracked it!

Cheers, naexpert.

Author

Commented:
I eventually found the syntax to add documents...

Adsutil.vbs set w3svc/defaultdoc "default.htm,default.html,default.asp,default.aspx,index.htm,index.html,index.
asp,index.aspx,temp.htm"

Thanks for your help.
Top Expert 2008

Commented:
Hi,

you do it the same way for documents.

use the 'enum' command demonstrated above to see what the existing context objects are, then use 'set' to change them.

e.g:

C:\Inetpub\AdminScripts>cscript adsutil.vbs enum W3SVC/1/Root/
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

KeyType                         : (STRING) "IIsWebVirtualDir"
AppRoot                         : (STRING) "/LM/W3SVC/1/Root"
.. etc ..

HttpExpires                     : (STRING) "D, 0"
DefaultDoc                      : (STRING) "Default.aspx,Default.htm,Default.asp,index.htm,iisstart.htm"
Path                            : (STRING) "C:\Inetpub\wwwroot\"

.. etc ..

MimeMap                         : (MimeMapList) ".special,some/special" ".special2,some/special2"
DirBrowseFlags                  : (INTEGER) 3221225534
EnableDirBrowsing               : (BOOLEAN) True
DirBrowseShowDate               : (BOOLEAN) True
DirBrowseShowTime               : (BOOLEAN) True
DirBrowseShowSize               : (BOOLEAN) True
DirBrowseShowExtension          : (BOOLEAN) True
DirBrowseShowLongDate           : (BOOLEAN) True
EnableDefaultDoc                : (BOOLEAN) True
AuthFlags                       : (INTEGER) 7

.. etc ..

EnableDirBrowsing               : (BOOLEAN) True
DirBrowseShowDate               : (BOOLEAN) True
DirBrowseShowTime               : (BOOLEAN) True
[/W3SVC/1/Root/aspnet_client]
[/W3SVC/1/Root/cgi-bin]
[/W3SVC/1/Root/WWW]

see in the list these two lines:


DefaultDoc                      : (STRING) "Default.aspx,Default.htm,Default.asp,index.htm,iisstart.htm"

and:

EnableDefaultDoc                : (BOOLEAN) True

This tells us that the DefaultDoc key is a comma delimited list of document names, and the enable default doc is a boolean.

so to set the DefaultDoc, we do:

adsutil.vbs enum W3SVC/1/Root/DefaultDoc "mydoc.html,Default.aspx,Default.htm,Default.asp,index.htm"

and to enable:

adsutil.vbs enum W3SVC/1/Root/EnableDefaultDoc True

cheers!
Top Expert 2008

Commented:
hey, you beat me to it! ;-)

I actually expected that you would work it out sooner or later - apparently 'sooner' ;-)

Cheers!

Author

Commented:
Thank you for your brilliant help, excellent!

Cheers, naexpert.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.