A service on the Web startup server

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.