Reprint: http://www.jb51.net/article/49627.htm
Reprint: http://blog.csdn.net/c1520006273/article/details/50539057
First, the direct use of CMD to service some of the operation
1. Installation Services
SC create test3 binpath= "C:\Users\Administrator\Desktop\win32srvDemo\win32srvdemo\Debug\win32srvDemo.exe"
Where: Test3 is the name of the service created, and BinPath is followed by the path where the exe file is run
2. Configuration Service
There are the following centralization methods:
sc config service name Start=auto (automatic)
sc config service name start= DEMAND (manual)
sc config service name start= DISABLED (disabled)
For example, the following command will start automatically on the XP system:
sc config test3 start= AUTO
3. Open Service
SC start test3
4. Close the service
sc stop Test3
5. Delete Service
SC Delete Test3
Second, for the convenience of use, can be edited as a bat batch file
(Create a new TXT file, name it yourself, and change the suffix to. bat file)
1. Create, configure, and open services
@echo. Service start ... @echo off@sc create test3 binpath= "C:\Users\Administrator\Desktop\win32srvdemo\win32srvdemo\Debug\ Win32srvdemo.exe "@net start test3@sc config test3 start= auto@echo off@echo. @pause
2. Close the service
@echo. Service shutdown @echo off@net stop Test3@echo Off@echo. Close the end! @pause
3. Delete Service
@echo. Service Delete @echo OFF@SC delete test3@echo off@echo. Delete End! @pause
Note:
REM indicates that the word identifier after this command is interpreted as a line (note), not executed, but for future reference (equivalent to comments in the program).
SC Command---Install, open, configure, and close Windows Service Bat batch (reprint)