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