Windows Service Wrapper 一個將可執行文件封裝為windows服務的利器


Windows Service Wrapper 一個將可執行文件封裝為windows服務的利器

License

WinSW是一個可執行二進制文件,可用於包裝和管理作為Windows服務的自定義進程。下載安裝包后,您可以將 WinSW.exe 重命名為任何名稱,例如 MyService.exe 。

支持的平台

WinSW提供了.NET Framework 2.0、4.0和4.6.1的可執行文件。它可以在安裝了這些版本的.NET Framework的Windows平台上運行。對於沒有.NET Framework的系統,該項目提供了基於.NET Core 3.1的本機64位和32位可執行文件。

下載

WinSW 可在 GitHub ReleasesNuGet上進行下載.

用法

WinSW通過配置文件(提供xml和yaml兩種格式)的方式進行管理: Main XML configuration file 和 Main YAML configuration file .

配置完成后,可配合以下命令進行windows服務的安裝、啟動、停止等操作:

  • install 將服務安裝到Windows Service Controller.
  • uninstall 卸載服務和上面相反的操作。
  • start 啟動服務,該服務必須已經安裝。
  • stop 停止服務。
  • stopwait 停止服務並等待,直到它實際上停止為止。
  • restart 重新啟動服務。如果該服務當前未運行,則此命令的作用類似於start
  • status 檢查服務的當前狀態。

大多數命令都需要管理員權限才能執行。

執行格式: MyService.exe install

XML配置格式

<service>
  
  <!-- ID of the service. It should be unique across the Windows system-->
  <id>gocron</id>
  <!-- Display name of the service -->
  <name>gocron Service (powered by WinSW)</name>
  <!-- Service description -->
  <description>This service is a crontab</description>
  
  <!-- Path to the executable, which should be started -->
  <executable>F:\gocron\gocron-windows-amd64\gocron.exe</executable>
  <startarguments> web </startarguments>
  <log mode="roll"></log>
</service>

備注: WinSW.exe 和對應的xml配置文件進行重命名時采用相同的文件名。如: myserver.exe myserver.xml


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM