1. Use the VS component "VS2012 Developer Command Prompt" tool to perform an on-load service (must be run as "Administrator")
When installing and uninstalling, select the appropriate installer tool address, for example:
Installation Services: C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe service Path
Uninstall Service: c:\windows\microsoft.net\framework\v4.0.30319\installutil.exe/u service path
For example:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe F:\ code example \demo\testservice\bin\debug\ TestService.exe
c:\windows\microsoft.net\framework\v4.0.30319\installutil.exe/u F:\ code example \demo\testservice\bin\debug\ TestService.exe
View and start the service
Open the 1.txt file under F disk to check if the service is working properly
2. Use batch file to carry out the loading and unloading service
Install.bat File Contents
@echo Installation Services
%systemroot%\microsoft.net\framework\v4.0.30319\installutil TestService.exe
@echo Start the service
net start Testservice
Uninstall.bat File Contents
@echo Uninstall Service
%systemroot%\microsoft.net\framework\v4.0.30319\installutil testservice.exe/u
Note:
1. Install.bat and Uninstall.bat files and service programs are placed in the same directory.
2. If there are multiple services in the solution, file names are suggested to change to this style: Testserviceinstall.bat and Testserviceuninstall.bat