C#IIS网站应用程序池启动回收停止
2014-04-30 14:56
393 查看
//添加应用程序池空间引用
using System.DirectoryServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Management;
private void button6_Click(object sender, System.EventArgs e)
{
//如果应用程序池不存在,则会报错系统找不到指定路径
string AppPoolName=this.textBox1.Text.Trim();
string method="Start";
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,"启动失败");
}
}
private void button7_Click(object sender, System.EventArgs e)
{
//如果应用程序池当前状态为停止,则会发生异常报错
string AppPoolName=this.textBox1.Text.Trim();
string method="Recycle";
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,"回收失败");
}
}
private void button8_Click(object sender, System.EventArgs e)
{
string AppPoolName=this.textBox1.Text.Trim();
string method="Stop";
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,"停止失败");
}
}
using System.DirectoryServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Management;
private void button6_Click(object sender, System.EventArgs e)
{
//如果应用程序池不存在,则会报错系统找不到指定路径
string AppPoolName=this.textBox1.Text.Trim();
string method="Start";
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,"启动失败");
}
}
private void button7_Click(object sender, System.EventArgs e)
{
//如果应用程序池当前状态为停止,则会发生异常报错
string AppPoolName=this.textBox1.Text.Trim();
string method="Recycle";
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,"回收失败");
}
}
private void button8_Click(object sender, System.EventArgs e)
{
string AppPoolName=this.textBox1.Text.Trim();
string method="Stop";
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,"停止失败");
}
}
相关文章推荐
- 网站排名不稳定的原因以及解决方法。
- i2c驱动架构 davinc dm368 i2c驱动分析
- 如何把自己写的网站项目发布到网上?
- 偶遇双主架构中dml语句无法在slave上执行。
- 网站收藏
- 如何把自己写的网站项目发布到网上?
- java 从网站下载图片到本地
- 理解 Android 2D/3D 图形架构
- 手机web网站前端开发布局技巧
- hadoop技术基本架构
- 网站权重与搜索排名的关系
- IIS网站的权限设置问题
- 百万级访问量网站的技术准备工作
- Hadoop 的分布式架构改进与应用
- Android的系统架构
- Windows CE SDHC驱动简析(1)-驱动架构(基于WinCE5.0 SMDK2410 BSP的SDHC驱动)
- 一般增加网站外部链接的方式有哪些
- 基于XMPP的IOS聊天客户端程序(XMPP服务器架构)
- 健壮且可读的安卓架构设计
- 读取目标文件的指令集,架构