The story is this:
Web page opens a list of data: Data requirements are available in real time from many other platforms.
So there's a Web page. There is also a winservice service to get these data at regular intervals ...
Here's the problem.
Discover that service is sometimes stopped for no reason. To the web side of the data rendering is troubled.
If you don't want to have a problem, run to the server and open the service. How to control the opening and closing of this service via the Web.
~~~~~~~~~~~~~~~~~~~~~ Open the whole ~~~~~~~~~~~~~~~~~~~~
First create a bat batch file: Do not know what is the http://baike.baidu.com/view/295769.htm of a batch file
Fill in the content:
NET START "Servicesname" //servicesname is the name of your service
Save As BAT file for example: start service. Bat
Put this file in a fixed location. It can be somewhere under the directory of your Web project. Anyway, you need to know.
The Web program writes such a piece of code
System.Diagnostics.Process p =NewSystem.Diagnostics.Process ();//Defining ProcessesP.startinfo.useshellexecute =true;//To start a process using the operating system shellP.startinfo.createnowindow =false;//set to False to see the program windowP.startinfo.windowstyle = Processwindowstyle.normal;//window state When starting a processp.StartInfo.FileName =@"d:\ Your Path \bat\ start the service. Bat";//bat file PathP.start (); //Start Executionp.WaitForExit ( the);//whether to wait until the execution of the bat file finishes executing: Or wait 3 seconds .P.close ();//End of execution
I copied the above code from somewhere else. I just added some notes ... Thank the Great God first.
Then here your local test should be no problem.
But it's not the same as sending it to the server.
Found that the bat could not be executed.
This is because you are using the VS execution program locally. You are using a local account. However, the server is using a network account. The privilege is very small.
The application for this site can be found in the Applicatiaon pool.
Properties---pre-defined account---(Network service changed to local System)--OK
The system will pop the window. Said it was very unsafe. It is also indeed unsafe. own discretion.
So far.. Web Management winservice Complete ...
A service on the Web startup server