//添加应用程序池空间引用
using System.DirectoryServices;
代码
string
method
=
"
Start
"
;
//
Start开启 Recycle回收 Stop 停止
string AppPoolName = " chengxuchiname " ;
try
{
DirectoryEntry appPool = new DirectoryEntry( " IIS://localhost/W3SVC/AppPools " );
DirectoryEntry findPool = appPool.Children.Find(AppPoolName, " IIsApplicationPool " );
findPool.Invoke(method, null );
appPool.CommitChanges();
appPool.Close();
MessageBox.Show( " 应用程序池名称启动成功 " , " 启动成功 " );
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, " 启动失败 " );
}
string AppPoolName = " chengxuchiname " ;
try
{
DirectoryEntry appPool = new DirectoryEntry( " IIS://localhost/W3SVC/AppPools " );
DirectoryEntry findPool = appPool.Children.Find(AppPoolName, " IIsApplicationPool " );
findPool.Invoke(method, null );
appPool.CommitChanges();
appPool.Close();
MessageBox.Show( " 应用程序池名称启动成功 " , " 启动成功 " );
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, " 启动失败 " );
}