Windows service combat (some small pits)

Refer to Microsoft Documentation: Creating a Windows Service

1. Follow the steps to create and install the service in the example, as shown in the figure below:

2. If the name of the service is modified in the code (MyService is changed to hxxService) and the service is regenerated (the service needs to be stopped), as shown in the figure below:

3. If you use the VS developer command line (via InstallUtil.exe) or PowerShell in the Microsoft document above, the uninstallation will fail

4. Uninstallation can only be performed by changing the service name back to "MyService" and regenerating it.

5. Uninstalling through the service name through WindowsServiceClient in the example is the same. The premise is to ensure that the service name of the installed service (installed version) that needs to be uninstalled is consistent with the service name of the existing service program (current version).

6. The service is different from the application that we usually use the installation package to install (after all, the installation methods are different), which needs attention.

Guess you like

Origin blog.csdn.net/qq_23958061/article/details/113842369