Some time ago to go out to interview, technical too many kinds of crazy abuse, and asked about the Windows services related things, and now sleep, up just a rough study of a, words do not say much.
Solution:
1. Open vs, new project-windows service
Open Services1.cs when creation is complete
2. Right-click the interface and add the installer
At this point, you will find several more files
To modify an account during installation
You can also modify the service name and service startup mode
3. Compile after modification, open the compiled EXE file
After compiling, you need InstallUtil.exe to install the service, open the framework default installation location, find this executable file
4. Open the cmd command prompt and go to the InstallUtil.exe directory, followed by the full path of the service after executing the installation service file
5. When the installation is complete, you can open the service and you can see that the MyService installation is successful.
Start the service and open Task Manager to see the service you just installed.
Appendix: After you create a new Windows service, install the service without adding the installer, you will get an error
The above can create a simple Windows service, you can get a bat file yourself to execute.
Install service command:
C \ Path \installutil.exe "service path \ Service. exe"
Uninstall Service Command:
C \ Path \installutil.exe/u "service path \ Service. exe"
Windows Service Creation