Adding Windows Services

A, cmd command line --- with the Windows operating services

1, installation services

sc create 服务名 binPath= "C:\Users\Administrator\Desktop\win32srvDemo\win32srvdemo\Debug\win32srvDemo.exe"

Note: Service name: Windows service name refers to the creation of

       binPath: refers to the path to the Windows service program

2, configuration services

sc config service names start = AUTO

Note: start = AUTO (automatic)

      start = DEMAND (manual)

      start = DISABLED (disabled)

3, open service

net start service name

4, close the service

net stop service name

5. Delete Service

sc delete service name

 

Second, the first: bat batch --- with the Windows operating services

(Create a txt file, change the extension .bat file)image

1, create, configure, start the service

Copy the code
. @echo service starts ......   
@echo OFF   
@sc the Create service name = binPath "C: \ the Users \ Administrator \ Desktop \ win32srvdemo \ win32srvdemo \ Debug \ win32srvdemo.exe"   
@net Start service name   
@sc config service name = AUTO start   
@echo OFF   
@echo. Booted!  
@pause
Copy the code

2, shut down service

Copy the code
@echo. Services Close   
@echo OFF   
@net STOP service name   
@echo OFF   
@echo. Close the end!  
@pause
Copy the code

3, delete the service ( before deleting to turn off service )

Copy the code
@echo. Service to delete   
@echo OFF   
@sc the Delete service name 
@echo OFF   
@echo. deletion end!  
@pause
Copy the code

Second, the second: bat batch --- with the Windows operating services

1, the installation script Install.bat

%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil.exe "E:\wwwroot\kjsmtt\wwwroot\KJLMManagerShareOutBonus\KJLMManagerShareOutBonus.exe"
Net Start 服务名
sc config Service Name = Auto Start 
PAUSE

Note: The first line: Window service program execution path

     Second row: Start Services

     Third row: Set the service to run automatically

     The last line: Pause, you can view operational information

2, uninstall script Uninstall.bat

%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil.exe /u "E:\wwwroot\kjsmtt\wwwroot\KJLMManagerShareOutBonus\KJLMManagerShareOutBonus.exe"
pause

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/wangcl-8645/p/11978319.html