Recently, a project needs a background service, timed to read the data, which is directly created a bat file, double-click on the execution can be, for the sake of trouble oh
The main points are two steps
1. Create the application for the Windows service. This does not do much to explain. There are too many examples on the web
2.bat file
Click on the project to add the class library, and then modify the. cs file to a. bat file to delete all contents.
Add the following content:
Create a service
SC create testservice binpath= "%cd%\testservice.exe" start= autopause
Where TestService.exe is the generated EXE file for the service project
The red part, I vs2005,2008, this is OK. Inside the vs2013, you need to manually fill in the file path where the TestService.exe resides.
Delete Service
SC Delete Testservice pause
C # easily creates WinDOS services with bat files