You may often encounter such a situation: the server suddenly breakpoints, the background of the program can not be automatically started as a service before the user logon , the following we use the Server background service automatic monitoring service as a portal for analysis.
Learning Reference:
Http://www.cnblogs.com/sorex/archive/2012/05/16/2502001.html
Http://jingyan.baidu.com/article/fa4125acb71a8628ac709226.html
Design environment: Visual Stdio C #. NET4.5
================================
Reference steps:
Add the system.serviceprocess the reference.
The pits encountered:
How to encode the executable file in ASNI encoded mode
Unable to uninstall some services: SC Delete Service name
Method Reference:
The first method:
1. Start and run->cmd
2. CD to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 (the Framework version number is configured by IIS)
3. Installation Service: Run command line InstallUtil.exe E:/test.exe
Uninstall Service: Run command line installutil.exe-u E:/test.exe
This can be deleted, but if it can not be deleted, there is a way below.
The second method:
Run-->cmd--> to C:\Windows\System32 folder and enter SC Delete < service name, and then you can uninstall the service
At this time, we can use another command to uninstall, as follows:
C:\WINDOWS\SYSTEM32>SC Delete MyService
The MyService is the name of your service, such as the following services, its uninstall command can be written as follows:
SC Delete "service name"
Of course you can also use this tool to create,start,stop the service. For example, we can install the service with the following command, and start the service up.
InstallUtil HongjunGuo.JobsWindowsService.exe
SC start "service name"
Windows service creation, debugging design, installation