Dim conn
Dim conndate
Dim sdb
Dim rs
Dim indexSql
sdb="tt.mdb" 'sdb 为各文件中设置的路径,请不要改动
conndata="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&sdb
'打开数据库连接
If IsObject(Conn) = false Then
Set Conn=CreateObject ("Adodb.Connection")
Conn.Open conndata
End if
DO
wscript.sleep 1000*5 '1000毫秒=1秒 设置定时扫描数据表时间,间隔
IndexSql="SELECT * FROM test where state=0 or templatesState=0 ORDER BY ID DESC "
Set rs=CreateObject("ADODB.RecordSet")
rs.open IndexSql,conn,1,1
Do while not rs.eof
' msgbox (rs("username"))
If rs("state")=0 then '为0时新注册用户生成站点
set objShell=CreateObject("WScript.shell")
objShell.run "cmd /c @iisweb /create E:/UserWeb/"&rs("username")&"/web1 "&rs("username")&" /i 192.168.1.55 /d "&rs("username")&".pur5.com /dontstart ",0, TRUE'生成站点
objShell.run "cmd /c @xcopy e:/web E:/UserWeb/"&rs("username")&" /e ",0, TRUE '复制所有模板到用户目录
objShell.run "cmd /c @iisweb /start "&rs("username")&" ",0, TRUE'启动当前添加的用户站点
End if
Dim websvc,computer,siteId,site
computer="localhost"
'wmi遍历查找IIS标识ID
Set websvc = GetObject("IIS://"&computer&"/w3svc")
For Each site In websvc
if site.class="IIsWebServer" then
if site.Servercomment=rs("username") then
'wscript.echo "site: " & site.Name & "="& site.Servercomment
siteId=site.Name
msgbox(siteId)
end if
end if
Next
If rs("templatesState")=0 then ' 为0时重新设定用户站点主目录
set objShell=CreateObject("WScript.shell")
objShell.run "cmd /c adsutil.vbs SET W3SVC/"&siteId&"/ROOT/Path ""e:/UserWeb/"&rs("username")&"/"&rs("templates")& "",0, TRUE
conn.execute("update test set templatesState=1 where username='"&rs("username")&"' ")'更新templatesState状态
End If
If rs("state")=0 then '更新templatesState状态
conn.execute("update test set state=1,siteId='"&siteId&"' where username='"&rs("username")&"' ")
End If
rs.movenext
loop
rs.close:Set rs=Nothing
LOOP
conn.close
set conn=Nothing