如何以编程方式(在vbscript中)更改/设置IIS下的站点的tcp端口?

时间:2008-10-29 10:43:11

标签: iis vbscript

我的编程环境包括在干净的机器上设置我的autobuild的脚本。

一步使用vbscript在IIS上配置用于监控构建的网站。

在特定的机器上,我将在端口80上运行apache以执行单独的任务。

我希望我的vbscript将端口设置为8080,以便添加新网站。

我该怎么做?

2 个答案:

答案 0 :(得分:2)

您需要使用WMI或ADSI

添加主机头

http://www.adopenstatic.com/cs/blogs/ken/archive/2006/07/28/188.aspx

那里的代码摘录(稍加编辑)

    Dim objWebApp
    Dim intArraySize
    Dim arrOldBindings
    Dim arrNewBindings

Set objWebApp = GetObject("IIS://localhost/w3svc/" WebSiteID)

If isArray(objWebApp.ServerBindings) then

arrOldBindings = objWebApp.ServerBindings
    intArraySize = UBound(arrOldBindings)
    Redim arrNewBindings(intArraySize + 1)

    For i = 0 to intArraySize
    arrNewBindings(i) = arrOldBindings(i)
    Next

arrNewBindings(intArraySize + 1) = ":mydomain.com:8080:"

    objWebApp.Put "ServerBindings", (arrNewBindings)
    objWebApp.SetInfo

End If

答案 1 :(得分:2)

您可以使用adsutil.vbs(IIS管理脚本的一部分)来更改:

cscript adsutil.vbs set W3SVC/1/ServerBindings “:8080:”

在默认布局中,脚本位于C:\Inetpub\AdminScripts\