遍历IIS站点(asp)

1.把iis的配置导出为文件iis_sitebackname.xml,放到asp根目录

2.asp文件

<%option explicit
dim fso
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
dim ts
Set ts = fso.OpenTextFile(server.MapPath("iis_sitebackname.xml"),1)  '修改此处的iis备份文件名即可,同目录下哦
dim content
content= ts.ReadAll

content=split(content,"ServerAutoStart")

function getdomain(str)
 dim reg,readstr,matches,match1
 set reg=new Regexp
  reg.Multiline=True
  reg.Global=false
  reg.IgnoreCase=true
  reg.Pattern="ServerComment(.*)\s"
  Set matches = reg.execute(str)
   For Each match1 in matches
    readstr=match1.Value
   Next
 Set matches = Nothing
 Set reg = Nothing
 getdomain=replace(readstr,"ServerComment=","")
 getdomain=replace(getdomain,"""","")
end Function
function getport(str)
 dim reg,readstr,matches,match1
 set reg=new Regexp
  reg.Multiline=True
  reg.Global=false
  reg.IgnoreCase=true
  reg.Pattern="ServerBindings(.*)\s"
  Set matches = reg.execute(str)
   For Each match1 in matches
    readstr=match1.Value
   Next
 Set matches = Nothing
 Set reg = Nothing
 getport=replace(readstr,"ServerBindings=","")
 getport=replace(getport,"""","")
 getport=replace(getport,":","")
end function

response.Clear()
dim i
for i=0 to ubound(content)
if instr(content(i),"ServerComment")>0 then
response.Write i&" <A HREF=http://localhost:"&getport(content(i))&">"&getdomain(content(i))&"</A><br>"
end if
next
%>

 备注:不要分配为固定IP,如果需要分配,修改部分代码.

标签: iis
posted @ 2009-03-11 09:14 狐狸v 阅读(109) 评论(0)  编辑 收藏

公告

昵称:狐狸v
园龄:3年7个月
粉丝:0
关注:0

搜索

 
 

友情链接

最新评论