Der Webdienst ist nicht unter Windows-Dienste aufgeführt. Es läuft unter IIS und um es zu stoppen/zu starten, müssen Sie den Anwendungspool stoppen/starten, unter dem dieser Dienst läuft. Wenn Sie dies remote planen, muss WMI auf dem Zielserver aktiviert sein. Für Ihre Bequemlichkeit einen Code bereitstellt, die dies für Sie tun:
public void PoolAction(String servername, String AppPoolName, String action)
{
StringBuilder sb = new StringBuilder();
ConnectionOptions options = new ConnectionOptions();
options.Authentication = AuthenticationLevel.PacketPrivacy;
options.EnablePrivileges = true;
ManagementScope scope = new ManagementScope(@"\\" +
servername + "\\root\\MicrosoftIISv2", options);
// IIS WMI object IISApplicationPool to perform actions on IIS Application Pool
ObjectQuery oQueryIISApplicationPool =
new ObjectQuery("SELECT * FROM IISApplicationPool");
ManagementObjectSearcher moSearcherIISApplicationPool =
new ManagementObjectSearcher(scope, oQueryIISApplicationPool);
ManagementObjectCollection collectionIISApplicationPool =
moSearcherIISApplicationPool.Get();
foreach (ManagementObject resIISApplicationPool in collectionIISApplicationPool)
{
if (resIISApplicationPool["Name"].ToString().Split('/')[2] == AppPoolName)
{
// InvokeMethod - start, stop, recycle can be passed as parameters as needed.
resIISApplicationPool.InvokeMethod(action, null);
}
}
Hinweis:
- Aktion enthalten 'Start' können 'Stop' oder 'Recycle'
- Konto unter denen Dieser Code muss auf dem Zielserver admin sein.
Wie WMI auf dem Server aktivieren
Wer kann mir helfen? –
hast du meinen Vorschlag versucht? – Yuri