=============================================================
' 感谢您使用ASP001工作室开发的实用函数程序
' HTTP://WWW.ASP001.NET
'=============================================================
'ASP001工作室为您提供订制程序开发、企业互联网拓展服务
'QQ:1974229
'E-Mail:Shenyangchuqi@tom.com
'更多程序下载请到HTTP://WWW.ASP001.NET
'=============================================================
'函数介绍:创建WebSite
'本函数使用ADSI,需要Administrators组用户权限
'函数名称:CreateWebSite(Computer,IPAddr,PortNum,HostName,WebSiteDirectory,LogDirectory,WebSiteInfo,GuestUserName,GuestUserPass,StartOrStop)
'程序开发:ASP001工作室 ChuQi
'用法:CreateWebSite 计算机名(一搬为LocalHost或127.0.0.1),站点IP地址,端口号,主机名,站点根目录,,LOG文件的目录站点说明,网站访问时所使用的帐号,网站访问时所用帐号的口令,是否启动站点
'例:CreateWebSite "LocalHost","127.0.0.123","80","www.test.net","E:\UserData\UserNum001","E:\UserData\UserNum001\LogFiles","wwwtest.net","IUSR_Num001_test.net","abc888",True
'=============================================================
Function CreateWebSite(Computer,IPAddr,PortNum,HostName,WebSiteDirectory,LogDirectory,WebSiteInfo,GuestUserName,GuestUserPass,StartOrStop)
Dim w3svc, WebServer, NewWebServer, NewDir
Dim Bindings, BindingString, NewBindings, SiteNum, SiteObj, bDone
On Error Resume Next
Err.Clear
'检测是否能够加载W3SVC服务(即WEB服务)
Set w3svc = GetObject("IIS://" & Computer & "/w3svc")
If Err.Number <> 0 Then '显示错误提示
response.write "无法打开: "&"IIS://" & Computer & "/w3svc"
response.end
End If
'检测是否有设定相同IP地址、端口及主机名的站点存在
BindingString = IPAddr & ":" & PortNum & ":" & HostName
For Each WebServer in w3svc
If WebServer.Class = "IIsWebServer" Then
Bindings = WebServer.ServerBindings
If BindingString = Bindings(0) Then
response.write "IP地址冲突:" & IPAddr & ",请检测IP地址!."
Exit Function
End If
End If
Next
'确定一个不存在的站点编号做为新建站点编号,系统默认WebSite站点编号为1,因此从2开始
SiteNum=2
bDone = False
While (Not bDone)
Err.Clear
Set SiteObj = GetObject("IIS://"&Computer&"/w3svc/"&SiteNum) '加载指定站点
使用ASP在IIS创建WEB站点的函数
内容版权声明:除非注明,否则皆为本站原创文章。