直接代码:

 

代码
using System.DirectoryServices; // 添加引用 System.DirectoryServices

try
{
DirectoryEntry appPool
= new DirectoryEntry("IIS://localhost/W3SVC/AppPools");
DirectoryEntry findPool
= appPool.Children.Find("DefaultAppPool", "IIsApplicationPool");
findPool.Invoke(
"Start", null); // Start|Stop|Recycle [Recycle:应用程序池回收,如果状态为Stop会报错]
appPool.CommitChanges();
appPool.Close();
Response.Write(
"DefaultAppPool 操作成功!");
}
catch (Exception ex)
{
Response.Write(
"DefaultAppPool 未找到!");
}

 

相关文章:

  • 2021-10-02
  • 2022-12-23
  • 2022-12-23
  • 2022-01-15
  • 2022-12-23
  • 2021-08-10
猜你喜欢
  • 2021-08-25
  • 2021-12-03
  • 2022-01-23
  • 2021-07-28
  • 2022-12-23
  • 2022-02-18
  • 2022-02-20
相关资源
相似解决方案