使用「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 訊息

使用「Visual Studio 2019」建置單元測試專案

在「Visual Studio 2019」使用「Markdown」撰寫文章

「Selenium」前端 UI 自動化測試、爬蟲程式 最佳利器

如何取得 FaceBook 的「應用程式編號」、「應用程式密鑰」。

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

快速的套件管理工具「Yarn」

「Git」安裝

使用「ADO.NET」 進行資料庫的讀取、新增、修改、刪除的操作