Service package software winsw

winsw (Windows Service Wrapper) is an open source project that allows us to quickly register an executable program as a Windows system service.

download

The download page is as follows: ( download link )

Insert picture description here
Need to download executable program ( WinSW.NET4.exe) and configuration file ( sample-minimal.xml).

  • The executable programs are WinSW.NET2.exeas well as those WinSW.NET4.exethat can be selected according to the .NET version of the current system. If it is Win10, it is recommended WinSW.NET4.exe.

  • The configuration file has sample-minimal.xmland sample-allOptions.xml, sample-allOptions.xmlincluding all configuration items, sample-minimal.xmlis the smallest configuration that can be used, and the conditions can be met by using this.

sample-minimal.xmlThe content is as follows:

<configuration>

  <!-- ID of the service. It should be unique accross the Windows system-->
  <id>myapp</id>
  
  <!-- Display name of the service -->
  <name>MyApp Service (powered by WinSW)</name>
  
  <!-- Service description -->
  <description>This service is a service cratead from a minimal configuration</description>
  
  <!-- Path to the executable, which should be started -->
  <executable>%BASE%\myExecutable.exe</executable>
  
</configuration>

Configuration

Take installation X:\Test.exeas an example, put WinSW.NE4.EXEand sample-minimal.xmlin the folder ( X:\winsw\), rename them to Test.exeand respectively Test.xml( must have the same name, otherwise it will fail ), and Test.xmlmodify it to:

<configuration>

  <!-- ID of the service. It should be unique accross the Windows system-->
  <id>100001</id>
  
  <!-- Display name of the service -->
  <name>Test</name>
  
  <!-- Service description -->
  <description>Service of Test</description>
  
  <!-- Path to the executable, which should be started -->
  <executable>X:\Test.exe</executable>
  
</configuration>

installation

With administrator privileges to run cmd , enter the directory X:\winsw\, run the command Test.exe installto complete the installation.

Other commonly used commands are as follows:

  • Test.exe uninstall
  • Test.exe start
  • Test.exe restart
  • Test.exe stop

other

If you need to set multiple programs, you need to set multiple configuration files. Winsw does not support one configuration file to set multiple programs.

reference

Use winsw to make any Windows program run as a service
. Use winsw for service management in windows. Turn on and start the service.

Guess you like

Origin blog.csdn.net/xp178171640/article/details/112247928