我有一个几年前写的vbscript,它列出了IIS服务器上具有各种属性的所有站点。我一直在尝试修改它以列出每个虚拟目录的路径,但是没有" application"也不是" applicationcollection"似乎是site元素的子元素。我查看了MS文档,但他们的示例代码仅显示添加应用程序,而不是列出它们。
这是我到目前为止所做的:
Set adminManager = Wscript.createObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set sitesSection = adminManager.GetAdminSection("system.applicationHost/sites", "MACHINE/WEBROOT/APPHOST")
Set sitesCollection = sitesSection.Collection
For siteCount = 0 To CInt(sitesCollection.Count)-1
Set siteElement = sitesCollection(siteCount)
'Various other bits here....
'Then this line doesn't work. I can't figure out how to reference the application
Set appCollection = siteElement.ChildElements.Item("applicationCollection").Collection
Next
Set adminManager = Wscript.createObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set sitesSection = adminManager.GetAdminSection("system.applicationHost/sites", "MACHINE/WEBROOT/APPHOST")
Set sitesCollection = sitesSection.Collection
For siteCount = 0 To CInt(sitesCollection.Count)-1
Set siteElement = sitesCollection(siteCount)
'Various other bits here....
'Then this line doesn't work. I can't figure out how to reference the application
Set appCollection = siteElement.ChildElements.Item("applicationCollection").Collection
Next
有人可以发布一些示例vbscript来列出网站的虚拟目录吗?
答案 0 :(得分:0)
最终在非常有用的IIS Configuration Reference的帮助下找到了这一点。现在显示" [application] physicalpath"
Set siteCollection = siteElement.Collection
spath = ""
For appCount = 0 To CInt(siteCollection.Count)-1
Set appElement = siteCollection.Item(appCount)
Set appCollection = appElement.Collection
For vdCount = 0 To CInt(appCollection.Count)-1
Set vdElement = appCollection.Item(vdCount)
spath = spath & "[" & CStr(appElement.Properties.Item("path").Value) & "] " & CStr(vdElement.Properties.Item("physicalPath").Value) & VbCrLf
Next
Next