zoukankan      html  css  js  c++  java
  • c# iis回收应用程序池

    Process p = new Process();
                    p.StartInfo = new ProcessStartInfo
                    {
                        FileName = @"c:windowssystem32inetsrvAppCmd.exe",
                        Arguments = "recycle apppool /apppool.name:xxx",
                        CreateNoWindow = true,
                        UseShellExecute = false,
                        RedirectStandardOutput = false,
                        RedirectStandardError = false
                    };
                    p.EnableRaisingEvents = true;
                    p.Start();
                    p.WaitForExit();

    或者下面方法

    using Microsoft.Web.Administration;

    var
    result = ""; ServerManager sm = new ServerManager(); var pool = sm.ApplicationPools["xxx"]; if (pool != null && pool.State == ObjectState.Stopped) { if (pool.Start() == ObjectState.Started) { result += "start ok!"; } } if(pool!=null && pool.State == ObjectState.Started) { if (pool.Recycle() == ObjectState.Started) { result += "recyle ok!"; } }

    下面的方法,在无权限的时候,可以试试

    进程里看w3wp对应的id是否有变化来判断是否重启成功,重启逻辑应该是先新增一个,再删除旧的,刚回收时,会同时存在两个进程。

  • 相关阅读:
    ecshop 整合 kindedotor
    css 一些小笔记
    linux 使用 随记录
    GIPZ 压缩
    js 代码 随记
    map和list循环遍历
    向数据库批量处理事件
    链表和数组的优劣比较
    内存对齐 和 sizeof小结
    C++的默认构造函数与构造函数
  • 原文地址:https://www.cnblogs.com/huanyun/p/12901161.html
Copyright © 2011-2022 走看看