使用ASP在IIS创建WEB站点的函数(2)
If (Err.Number = 0) Then
'response.write " Step_1站点"&SiteNum&"存在 "
SiteNum = SiteNum + 1
Else
'response.write " Step_1站点"&SiteNum&"不存在 "
Err.Clear
Set NewWebServer = w3svc.Create("IIsWebServer",SiteNum) '创建指定站点
If (Err.Number <> 0) Then
'response.write " Step_2站点"&SiteNum&"创建失败 "
SiteNum = SiteNum + 1
Else
'response.write " Step_2站点"&SiteNum&"创建成功 "
bDone = True
End If
End If
If (SiteNum > 50) Then '服务器最大创建站点数
response.write "超出服务器最大创建站点数,正在创建的站点的序号为: "&SiteNum&"."
response.end
End If
Wend
'进行站点基本配置
NewBindings = Array(0)
NewBindings(0) = BindingString
NewWebServer.ServerBindings = NewBindings
NewWebServer.ServerComment= WebSiteInfo
NewWebServer.AnonymousUserName= GuestUserName
NewWebServer.AnonymousUserPass= GuestUserPass
NewWebServer.KeyType = "IIsWebServer"
NewWebServer.FrontPageWeb = True
NewWebServer.EnableDefaultDoc = True
NewWebServer.DefaultDoc = "Default.htm, Default.asp, Index.htm, Index.asp"
NewWebServer.LogFileDirectory= LogDirectory
NewWebServer.SetInfo
Set NewDir = NewWebServer.Create("IIsWebVirtualDir", "ROOT")
NewDir.Path = WebSiteDirectory
NewDir.AccessRead = true
NewDir.AppFriendlyName = "应用程序" & WebSiteInfo
NewDir.AppCreate True
NewDir.AccessScript = True
Err.Clear
NewDir.SetInfo
If (Err.Number = 0) Then
Else
response.write "主目录创建时出错."
response.end
End If
If StartOrStop = True Then
Err.Clear
Set NewWebServer = GetObject("IIS://" & Computer & "/w3svc/" & SiteNum)
NewWebServer.Start
If Err.Number <> 0 Then
response.write "启动站点时出错!"
response.end
Err.Clear
Else
End If
End If
response.write "站点创建成功,站点编号为:"& SiteNum &" ,域名为:"& HostName
End Function
内容版权声明:除非注明,否则皆为本站原创文章。