. NET Creating and installing Windows Service cases

Source: Internet
Author: User
Tags net command

1. Create a Windows Service "reference blog post":

1. Switch this service program to Design view
2. Right-click on Design view and select "Add Installer"
3. Switch to the Design view of the newly added ProjectInstaller
4. Set the properties of the ServiceInstaller1 component:
1) ServiceName = My Sample Service
2) StartType = Automatic
5. Set the properties of the ServiceProcessInstaller1 component
1) account = LocalSystem
6. Build a solution

Note: If you try to enable multi-service at the same time, the personal test did not succeed!

Servicebase[] ServicesToRun;
ServicesToRun = new servicebase[]
{
New Nfsmainservice ()
};
Servicebase.run (ServicesToRun);

Servicebase[] When you put multiple services in an array, you can only run the first one, read a lot of posts but not solve them, but we can put multiple services into a service in the form of classes.

2. There are two ways to install the service:

1. Install through the InstallUtil Program: Open Visual Studio. NET command, Format: path InstallUtil.exe MyWindowsService.exe;

Uninstall words: Format: path InstallUtil.exe mywindowsservice.exe/u

However, if deployed to the client side, the production environment may not have visual Studio. NET command, in which case we can either package the service or use the cmd command:

SC Create service name binpath= E:\Test\WindowsApplication1\WindowsService1\bin\Debug\ WindowsService1.exe, enter;

You need to add a space after binpath=.

Unloading:

SC Delete Service Name

. NET Creating and installing Windows Service cases

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.