IIS Scripting: Add Host Headers

Following my previous post about IIS Scripting, I would like to show you a quick way to add multiple Host Header to an IIS Web Site.

This simple VBScript load the host header configuration into an array and then add a list of Host Headers (e.g. www.mysite.com, www.vittorio.tk...) from a text file located into C:\NewHostHeader.txt


Dim IISOBJ, Bindings, Parts, BindingValue
Dim filesys, filetxt

'Get the mimemap object.
Set IISOBJ = GetObject("IIS://localhost/W3SVC/1")

Bindings= IISOBJ.ServerBindings
Index = UBOund(Bindings)

Set filesys = CreateObject("Scripting.FileSystemObject")
Set filetxt = filesys.OpenTextFile
("C:\NewHostHeader.txt", 1, True)
Do Until filetxt.AtEndOfStream
host = filetxt.Readline
Redim Preserve Bindings(index + 1)
Bindings(Index) = ":80:" & host
index = index + 1
Loop
filetxt.Close

IISOBJ.ServerBindings = Bindings
IISOBJ.SetInfo
Tags:

About author

Vittorio Pavesi

1 comments

  1. Hi, Your blog is really outstanding. You have seemed to do a nice part of your job. Please take some time to visit my site if you are looking for cheap web hosting.

Post a Comment