开发者

IIS Restart (cannot start any process and call iisreset) from the website itself

开发者 https://www.devze.com 2023-04-09 04:01 出处:网络
public s开发者_如何学编程tatic void RestartIIS() { string path = Environment.GetFolderPath(Environment.SpecialFolder.System) + @\"\\iisreset.exe\";
public s开发者_如何学编程tatic void RestartIIS()
{
    string path = Environment.GetFolderPath(Environment.SpecialFolder.System) + @"\iisreset.exe";
    System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo(path);
    info.UseShellExecute = true;
    System.Diagnostics.Process.Start(info);
}


You'll need to have administrative permissions to do this; running IIS as administrator is absolutely not recommended!

Rather, I'd suggest that instead of trying to administer the site from itself you work with one of the remote access / remote management tools. Something like the remote administration for IIS is basic but useable: http://learn.iis.net/page.aspx/158/remote-administration-for-iis-manager/.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号