2013-02-05 20 views
2

我需要在Windows Server 2003的IIS 6中通過其名稱獲取網站的ID。我使用C#做了它,但後來發現服務器沒有.Net框架安裝。我只知道網站的名稱。使用命令行獲取IIS 6中的網站ID

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。任何人都可以幫助我嗎?

請讓我知道,如果我不夠清楚,或者如果我需要提供更多的信息。

回答

-1

它看起來像IisApp.vbs是建議的選項。查看documentation。對不起,如果這不是你所需要的。

+0

它需要網站ID .....我需要找到網站ID。我害怕,但我是在別的東西:) – Sandy

+0

也許我讀錯了,但不是可選?普通命令將顯示應用程序池中的所有進程。 – Gray

+0

我剛剛在談論網站,而不是應用程序池..... – Sandy