Because the soft encryption service process of the company's internal network server may become stuck at an irregular time, you need to manually close the process and start it again. Every time a similar problem occurs, you always need to use a remote server or enter the data center to operate the machine, but sometimes it is not very convenient at night, but remote passwords and data center keys are not convenient for others, so think of the following solutions.
Create a BAT batch file to stop and start the service through stop/start, just as there is already IIS + on the server. NET2.0 writes An aspx page, allowing employees to access this page and click the bottom event to execute the BAT file.
Below is the C # source code
Using System;
Using System. Collections. Generic;
Using System. Web;
Using System. Web. UI;
Using System. Web. UI. WebControls;
Namespace WebApplication3
{
Public partial class _ Default: System. Web. UI. Page
{
Protected void Page_Load (object sender, EventArgs e)
{
}
Protected void button#click (object sender, EventArgs e)
{
System. Diagnostics. ProcessStartInfo pro = new System. Diagnostics. ProcessStartInfo ("cmd.exe ");
Pro. UseShellExecute = false;
Pro. RedirectStandardOutput = true;
Pro. RedirectStandardError = true;
Pro. Arguments = "/k d: \ jiamiError \ test. bat ";
Pro. WorkingDirectory = "D :\\ jiamiError \\";
System. Diagnostics. Process proc = System. Diagnostics. Process. Start (pro );
System. IO. StreamReader sOut = proc. StandardOutput;
Proc. Close ();
String results = sOut. ReadToEnd (). Trim ();
SOut. Close ();
String fmtStdOut = "<font face = courier size = 0> {0} </font> ";
This. Response. Write (String. Format (fmtStdOut, results. Replace (System. Environment. NewLine, "<br> ")));
/* Response. Write ("<script> alert ('fix successful! '); </Script> ");*/
/* Response. Redirect ("Success.html ");*/
}
}
}
Author: YoungIvan