直接代码:
代码
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 未找到! " );
}
本文转自王磊的博客博客园博客,原文链接:http://www.cnblogs.com/vipstone/archive/2011/01/11/1932717.html,如需转载请自行联系原作者