简体   繁体   中英

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

public static 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/ .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM