Create an install.bat file
@ECHO OFF echo ready to install service pause echo install service... echo --------------------------------------------------- % SystemRoot% \ Microsoft.NET \ Framework \ v4.0.30319 \ installutil.exe% ~ dp0 \ DemoService.exe net start DemoService sc config DemoService start=auto echo --------------------------------------------------- echo installation service successful! pause
Call the installutil.exe program of .NET Framework to install the service.
After the installation is successful, start the service through net start DemoService.
sc config Demoservice start=auto The startup type of the configuration service is automatic, which is equivalent to booting.
Create an uninstall.bat file
@ECHO OFF echo prepare to uninstall service pause echo uninstall service... echo --------------------------------------------------- % SystemRoot% \ Microsoft.NET \ Framework \ v4.0.30319 \ installutil.exe% ~ dp0 \ DemoService.exe -u sc delete DemoService Net Stop DemoService echo --------------------------------------------------- echo Uninstall service succeeded! pause