Windows Service Deployment

Source: Internet
Author: User

1. Create a new Windows Service project

2. Edit the business code

I'm just writing a 2-sentence test code for the recorded text.

usingSystem;usingSystem.IO;usingsystem.serviceprocess;namespacewindowsservice{ Public Partial classService:servicebase { PublicService () {InitializeComponent (); }        protected Override voidOnStart (string[] args) {System.IO.File.AppendAllText (Path.Combine (AppDomain.CurrentDomain.BaseDirectory,"Log.txt"),string. Format ("{0} I'm starting.", DateTime.Now)); }        protected Override voidOnStop () {System.IO.File.AppendAllText (Path.Combine (AppDomain.CurrentDomain.BaseDirectory,"Log.txt"),string. Format ("{0} I'm stopping.", DateTime.Now)); }    }}
View Code

3. Add the Installer

4. Setting the ProjectInstaller property


These 2 can be set as shown above

Below to import the bat culture separately

Installutil.bat (Installation)

WindowsService.exe Program Name
Testservice the service name set above ServiceName
InstallUtil windowsservice.exenet Start Testservicepause

Startservice.bat (Start service)

net start Testservicepause

Stopservice.bat (stop service)

net stop Testservicepause

Unintall.bat (uninstall)

InstallUtil/u windowsservice.exepause

Put this 4 file under the root directory and set it to always replicate.

There is also a file InstallUtil.exe also need to be set to always copy
Finish these operations and then generate some programs to the bin directory by double-clicking the Installutil.bat installation

Download Demo

Ext.: http://www.cnblogs.com/liuxiaoji/p/4779024.html

Windows Service Deployment

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.