简体   繁体   中英

How does one Reset IIS/Run Batch files via an ASP.NET MVC 4 Web Application Remotely?

I am trying to make a web service for my MVC C# app that will allow administrators to perform an iis reset by triggering a batch file with all the commands we use.

The website is hosted on a remote machine so this is not local. Security is in place for the web service to prevent this being triggered maliciously.

How would I go about doing this? I've tried

System.Diagnostics.Process.Start(@"c:\iisresetTest.bat");

This gave no errors, but it did not perform the reset.

I've also tried the directions here: http://labs.ratchet.com/566/running-command-line-bat-files-from-web-page-asp-net-c/

But that gave an error that I need to be an admin to run the command. I'm assuming the first line of code worked, but since it wasn't an admin it probably just closed down command prompt.

You can run a bat file as administrator using the scheduled task work around http://www.sevenforums.com/general-discussion/307201-how-run-batch-bat-flle-administrator.html I couldnt find the better page for that but you might find it googling. You can also go in the registry and turn UAC off but that could be dangerous.

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