<!--#include file="conn.asp"-->
<%
'response.end '//这是做调试时用的
on error resume next
set rs=server.createobject("adodb.recordset")
rs.activeconnection = myconnection
sql="select * from 你的表名 where 你指定的条件"
rs.open sql,,1,2
if rs.eof then response.end '//如果无符合条件记录,则停止
rs.movefirst
dim namestr '//定义虚拟目录名变量
do while not rs.eof
if instr(1,namestr,server.htmlencode(trim(rs("suname"))))<>0 then rs.movenext
name=name&server.htmlencode(trim(rs("suname")))
%>
<%
scomputer ="localhost"
sphydir = "x:\test\" & server.htmlencode(trim(rs("suname"))) '//这里定义虚拟目录指向的物理路径
svirdir = server.htmlencode(trim(rs("suname"))) '//这里定义虚拟目录名
set websvc = getobject("iis://" & scomputer & "/w3svc/1") '//获得你当前站点对象。若有多个站点,那么改动后面1为2,3...即可指向其它的
set vroot = websvc.getobject("iiswebvirtualdir", "root") '//获得当前站点虚拟root
set classdefinition = getobject(vroot.schema) '//获得虚拟目录的类定义
asmusthaves = classdefinition.mandatoryproperties
asmayhaves = classdefinition.optionalproperties
i=1
%>
<table border=1>
<tr><th>class must have property</th>
<th>root virtual directory current value</th></tr>
<%
on error resume next
for each thing in asmusthaves
response.write "<tr><td>("& cstr(i) & ") " &_
thing & "</td><td>" & vroot.get(thing) &_
"</td></tr>"
i = i + 1
next
%>
</table>
<table border=1>
<tr><th>class may have property</th>
<th>当前站点</th></tr>
<%
i=1
for each thing in asmayhaves
response.write "<tr><td>("& cstr(i) & ") " &_
thing & "</td><td>" & vroot.get(thing) &_
"</td></tr>"
i = i + 1
next
on error goto 0
'//建立虚拟目录
response.write svirdir & "
"
set vdir = vroot.create("iiswebvirtualdir",svirdir)
'//设置虚拟目录的两个属性,这里设置可读属性和将虚拟目录的路径指向物理路径
vdir.accessread = true
vdir.path = sphydir
vdir.setinfo '//将信息写入库,指的iis站点相关的库,不是你的用户数据表
%>
<%
rs.movenext
loop
rs.close
response.write "创建虚拟目录完成!"
%>
另外,还有利用adsi进行站点设置比如建站点,删除站点,配置站点ip,主机头,默认文档的等等,这里不做下载,有兴趣的朋友可以到微软站点下载 adsisdk 的开发文档深入。
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器