温州广电被黑,绵阳博文招聘,2626小游戏
重启站点:
throw new invalidoperationexception("could not find website!");
}
}
catch (exception e)
{
console.writeline(e);
}
}
/// <summary>
/// 重启完之后.要再检测下.是否开启了
/// </summary>
/// <param name="sitename"></param>
static void fixwebsite(string sitename)
{
try
{
var server = new servermanager();
var site = server.sites.firstordefault(s => s.name == sitename);
if (site != null)
{
if (site.state != objectstate.started)
{
thread.sleep(500);
//防止状态为正在开启
if (site.state != objectstate.started)
{
site.start();
}
}
}
}
catch (exception e)
{
console.writeline(e);
}
}
重启iis线程池:
/// <summary>
/// 运行cmd命令
/// </summary>
/// <param name="cmd">命令</param>
/// <returns></returns>
public static string cmd(string[] cmd)
{
process p = new process();
p.startinfo.filename = "cmd.exe";
p.startinfo.useshellexecute = false;
p.startinfo.redirectstandardinput = true;
p.startinfo.redirectstandardoutput = true;
p.startinfo.redirectstandarderror = true;
p.startinfo.createnowindow = true;
p.start();
p.standardinput.autoflush = true;
for (int i = 0; i < cmd.length; i++)
{
p.standardinput.writeline(cmd[i]);
}
p.standardinput.writeline("exit");
string strrst = p.standardoutput.readtoend();
//debug.print(strrst);
p.waitforexit();
p.close();
return strrst;
}
/// <summary>
/// 关闭进程
/// </summary>
/// <param name="procname">进程名称</param>
/// <returns></returns>
public static bool closeprocess(string procname)
{
bool result = false;
var proclist = new arraylist();
foreach (process thisproc in process.getprocesses())
{
var tempname = thisproc.tostring();
int begpos = tempname.indexof("(") + 1;
int endpos = tempname.indexof(")");
tempname = tempname.substring(begpos, endpos - begpos);
proclist.add(tempname);
if (tempname == procname)
{
if (!thisproc.closemainwindow())
thisproc.kill(); // 当发送关闭窗口命令无效时强行结束进程
result = true;
}
}
return result;
}
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Net Core Web Api项目与在NginX下发布的方法
asp.net core3.1 引用的元包dll版本兼容性问题解决方案
IdentityServer4实现.Net Core API接口权限认证(快速入门)
ASP.NET Core MVC通过IViewLocationExpander扩展视图搜索路径的实现
网友评论