使用「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 服務畫面即可看到剛剛的服務
留言
張貼留言