列出 IIS 5,6 和 7 中的所有虚拟目录 [英] List all virtual directories in IIS 5,6 and 7

查看:15
本文介绍了列出 IIS 5,6 和 7 中的所有虚拟目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个包含 IIS 站点内所有虚拟目录的列表.但是,我发现在旧版本的 IIS 中尝试执行此操作会有很大差异.在 IIS 7 中,这是通过 C# 进行的相对容易的任务,但我似乎找不到在 IIS 6 和 5 中执行此操作的好方法.

I am trying to create a list of all virtual directories within an IIS site. However, I have found that trying to do this varies dramatically in the older versions of IIS. In IIS 7 this is a relatively easy task via C# but I can't seem to find a good method for doing this in IIS 6 and 5.

我尝试过使用 System.DirectoryServices.DirectoryEntry 但这似乎没有给我想要的输出.

I have tried using the System.DirectoryServices.DirectoryEntry but that doesn't seem to give me the desired output.

我是服务器管理员,因此我愿意使用其他内容,例如 IIS 内置的 .vbs 文件以及编写自己的代码.

I am the server administrator so I'm open to using other things such as .vbs files that are built into IIS as well as writing my own code.

推荐答案

您是否尝试过使用 GetObject("IIS://ServerName/W3SVC")

have you tried using GetObject("IIS://ServerName/W3SVC")

你在 VBS 中这样做

You do it in VBS like this

'Get the IIS Server Object
Set oW3SVC = GetObject("IIS://ServerName/W3SVC/1/ROOT")

For Each oVirtualDirectory In oW3SVC

    Set oFile = CreateObject("Scripting.FileSystemObject")
    Set oTextFile = oFile.OpenTextFile("C:Results.txt", 8, True)

    oTextFile.WriteLine(oVirtualDirectory.class + " -" + oVirtualDirectory.Name)
    oTextFile.Close

Next
Set oTextFile = Nothing
Set oFile = Nothing

Wscript.Echo "Done"

我在这里有一篇关于它的文章 -> http://anyrest.wordpress.com/2010/02/10/how-to-list-all-websites-in-iis/

I have an article about it here -> http://anyrest.wordpress.com/2010/02/10/how-to-list-all-websites-in-iis/

这篇关于列出 IIS 5,6 和 7 中的所有虚拟目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆