- 新增專案
- 在ProjectInstaller 中,填入服務名稱 & 服務敘述
- 專案屬性中,(Debug 用,可以本機 Console.Write) 修改輸出類型 "主控台應用程式"
- 在 program.cs 中,加入 指令碼
static void onInstall(string[] args) { if (args.Length > 0) { switch (args[0]) { case "-install": case "-i": { ManagedInstallerClass.InstallHelper(new string[] { Assembly.GetExecutingAssembly().Location }); break; } case "-uninstall": case "-u": { ManagedInstallerClass.InstallHelper(new string[] { "/u", Assembly.GetExecutingAssembly().Location }); break; } } } }
- 重建專案(預設路徑~/bin/Debug),並複製到遠端
- 遠端放置檔案資料夾中,shift + 右鍵 開啟檔案總綰
- 鍵入 service -i ,成功會看到服務備安裝在服務清單中
留言
張貼留言