Windows Services are different from other common services. Windows ApplicationProgram, You cannot simply run EXE File to start it. Windows Service should be used . NET Framework Provided Installutil.exe Or use a deployment project, such Microsoft Installer ( Msi ) File.
Add installer
Only created Windows Service unavailable InstallutilProgram to install it. You must give it to you. Windows Add an installer for the service. Installutil Or other tools to know the specific configuration of the service.
1. Switch to the service design mode
2. Right-click and choose add installer
3. Switch to the new Projectinstaller Design Mode
4. Set Serviceinstaller1 Component attributes:
Servicename = My Sample Service
Starttype = automatic
5.Set Serviceprocessinstaller1 Component attributes:
Account = LocalSystem
6. Generate a solution
UseInstallutilInstallWindowsService
Now you need to install your service. Follow the steps below to install your service.
1.OpenVisual StudioCommand Prompt
2.Switch to storageWindowsService generated. ExeFile directory;
3. enter installutil youservice.exe to register your service, it will add the required registry information.
4. right-click my computer on the desktop, and choose manage.
5. select a service in the service and application, and you can see your service in the list
6. right-click your service and choose start
if you need to change your Windows service anytime, You Need To uninstall and reinstall it. Before detaching a service, you must close the Service Management Console. Otherwise, problems may occur during detaching. To uninstall the service, you only need to enter the same command as when registering, but add /u next to it.