直接代码:

代码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 未找到! " );
}
本文标题:c# 操作IIS应用程序池
本文链接:https://blog.quwenai.cn/post/5228.html
版权声明:本文不使用任何协议授权,您可以任何形式自由转载或使用。






还没有评论,来说两句吧...