iis.zip
1.将以下代码另存为iis.asp
2.将C:\Windows\System32\inetsrv\MetaBase.xml
文件或IIS 备份文件改名为IIS.xml
3.将两文件放入IIS
里某个站点里,使用浏览器访问iis.asp页面例如 :http://localhost/iis.asp 即可查看结果,效果图如下,如需要放入Excel里
直接复制粘贴到Excel !
<%
'修改了基本函数,可以导出任意你想的数据
option
explicit
dim FSO
Set FSO =
Server.CreateObject("Scripting.FileSystemObject")
dim ts
Set ts =
fso.OpenTextFile(server.MapPath("iis.xml"),1) '修改此处的iis备份文件名即可,同目录下哦
dim
content,contentdir,arraylocal
content=
ts.ReadAll
contentdir=content
content=split(content,"
'取主相关字段
'splitStr可以为你想要截取的标识如:ServerComment、AppFriendlyName、Path
function
getStr(str,splitStr)
dim reg,readstr,matches,match1
set reg=new
Regexp
reg.Multiline=True
reg.Global=false
reg.IgnoreCase=true
reg.Pattern=splitStr&"(.*)\s"
Set
matches = reg.execute(str)
For Each match1 in matches
readstr=match1.Value
Next
Set matches = Nothing
Set reg =
Nothing
getStr=replace(readstr,splitStr&"=","")
getStr=replace(getStr,"""","")
end
function
'取字段
function GetKey(HTML,Start,Last)
dim
filearray,filearray2
filearray=split(HTML,Start)
filearray2=split(filearray(1),Last)
GetKey=filearray2(0)
End
function
function Clear(content)
dim
arr,i
arr=split(content,":")
for i=0 to ubound(arr)
if
instr(arr(i),".")>0 then
Clear=Clear &
arr(i)&"
"
end if
next
end function
function
Clearport(content)
dim arr,i
arr=split(content,":")
for i=1 to
ubound(arr)
if instr(arr(i),".")=0 then
Clearport=Clearport &
arr(i)&"
"
end if
next
end
function
response.Clear()
dim
i,lc,contentdirs
response.Write("
编号 | 运行 | 描述 | 域名 | 端口 | 目录 | 标识 | ")
"&i&" | "&getStr(content(i),"ServerAutoStart")&" | "&getStr(content(i),"ServerComment")&" | "&Clear(GetKey(content(i),"ServerBindings=""",""""))&" | "&Clearport(GetKey(content(i),"ServerBindings=""",""""))&" | "&replace(getStr(content(i),"Path="),"Path=","")&" | "&rtrimVBcrlf(lc(3))&" |
'去掉字符串空格
function rtrimVBcrlf(str)
dim pos,isBlankChar
pos=len(str)
isBlankChar=true
while isBlankChar and pos>=2
if mid(str,pos,1)=" " then
pos=pos-1
elseif mid(str,pos-1,2)=VBcrlf then
pos=pos-2
else
isBlankChar=false
end if
wend
rtrimVBcrlf=rtrim(left(str,pos))
end function
%>