Directory
I,What is a Windows service?
2. Create a Windows Service andInstall/uninstall the batch.
3. debug the Windows service.
Body
1. What is a Windows service?
A: Microsoft Windows Services (formerly NT Services) enable you to create executable applications that can run for a long time in their own Windows sessions.Program. These services can be automatically started when the computer is started. They can be paused and restarted without displaying any user interface. This makes the service very suitable for use on the server, or any time, in order not to affect other users working on the same computer, it needs to be used for a long time to run the function. You can also run the service in a security context different from the logon user's specific user account or default computer account.
2. Create a Windows service.
Open: Visual Studio 2010 => New => project => Windows service,
Right-click the generated service1.cs File View and choose => Add Installer =>GeneratedOn the projectinstaller. CS view page, set the startup method and Windows Service name in serviceinstaller1,
Then, in setting the account information of serviceprocessinstaller1, select "Local System",
So far, the installation program and framework have been set up, and then on the onstart of service1.csCodeWrite your own business code in the view,
Now, the complete Windows service has been created.
The batch code for installing the service:
"% SystemRoot % \ Microsoft. NET \ framework \ v4.0.30319 \ installutil.exe"F: \ XXX \ xxx.exe Net start"Service name"
Batch code for uninstalling a service:
Net stop"Service name""% SystemRoot % \ Microsoft. NET \ framework \ v4.0.30319 \ installutil.exe"/U F: \ XXX \ xxx.exe
3. debug the Windows service.
In the Visual Studio 2010 toolbar, choose tools> attach to process => click OK, and select the name of the service to be debugged in the list. Click Add to debug the service. In the program, you only need to press F9 to debug it. Note that the Windows Service version must be consistent.
End
Windows service is actually very simple. Sort it out for the people you need. If it is useful, click support. Thank you.