使用「Visual Studio 2019」建置 Windows 服務

一、開發環境

  • 整合開發環境:Visual Studio 2019
  • 語言:C#
  • .net framework:4.6.2

二、建置 Windows 服務專案

圖、開啟 Visual Studio 2019,點 建立新的專案

圖、選擇 Windows 服務(.net framework)

圖、輸入相關資訊

圖、選擇 Service1.cs > 滑鼠右鍵 > 檢視原始碼,即可看到 Windows 服務 起初的原始碼

圖、對 專案 > 滑鼠右鍵 > 重建,即可在 bin 資料夾底下見到建置好的結果


三、登錄 Windows 服務

圖、輸入登錄指令

指令

sc create 服務名稱 binpath=D:\服務路徑\XXX.exe start=auto

圖、Windows 服務畫面即可看到剛剛的服務

四、相關連結

  1. 使用「SC」指令 登錄、刪除 Windows 服務

五、參考

  1. sc 指令

留言

這個網誌中的熱門文章

使用「LINE Messaging API」發送 line 訊息

如何傳送訊息至「Teams」的 Channel

讓 JavaScript 能在伺服器端執行的環境 「node.js」

使用 Visual Studio 2019 實作「RESTful API」

好用的資料庫管理工具「SQL Server 資料庫專案」

asp.net 下的 JSON 套件最佳利器「Newtonsoft.Json」

「Katalon Recorder」簡化測試腳本撰寫的工具

在「Visual Studio 2019 」使用 「NuGet」 安裝第三方套件