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
Share on Google Plus

About Vittorio Pavesi

    Blogger Comment
    Facebook Comment

0 commenti: