【问题标题】:Get website's ID in IIS 6 using the command line使用命令行在 IIS 6 中获取网站的 ID
【发布时间】:2013-01-20 01:40:05
【问题描述】:

我需要在 Windows server 2003 的 IIS 6 中通过其名称获取网站的 ID。我使用 C# 完成此操作,但后来发现服务器没有安装 .Net 框架。我只知道网站的名称。

string directoryEntry = string.Format("IIS://localhost/w3svc");
var w3Svc = new DirectoryEntry(directoryEntry);
foreach (DirectoryEntry de in w3Svc.Children) {
  if (de.SchemaClassName == "IIsWebServer" && de.Properties["ServerComment"][0].ToString() == "MyWebsiteName") {
    Environment.ExitCode = Convert.ToInt32(de.Name);
    return;
  }
}
int id = Process.Start("MyApp.exe");

我必须运行一个批处理文件才能在远程机器上启动和停止网站。我可以使用PSexec 运行批处理来启动和停止网站,但我不知道如何动态获取网站的 ID。有人可以帮我解决这个问题吗?

如果我不够清楚或需要提供更多信息,请告诉我。

【问题讨论】:

    标签: iis batch-file web iis-6 identifier


    【解决方案1】:

    看起来 IisApp.vbs 是推荐的选项。查看documentation 。抱歉,如果这不是您需要的。

    【讨论】:

    • 它需要网站 ID ......我需要找到网站 ID。我很害怕,但我在追求别的东西:)
    • 也许我读错了,但这不是可选的吗?普通命令将显示应用程序池中的所有进程。
    • 我刚看到你的另一篇文章,哈哈。这是否意味着它看起来是正确的方法?还是你不太确定?
    • 我不知道你在诚实地问什么......??请你能具体一点。如果你能提供,我很高兴知道正确的方法
    • question 中,您说您使用的是我建议的 iisapp.vbs。这是否意味着它可以完成您需要它做的事情?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-03
    相关资源
    最近更新 更多