1. 安裝
- 新建文本文件,重命名為 ServiceInstall.bat,將 ServiceInstall.bat 的內容替換為:
sc create "Verity Platform Device Service" binPath= "%~dp0WindowsService_HardwareDevice.exe"
sc description "Verity Platform Device Service" "提供設備連接、FMC 電壓、PLL 時鍾、FPGA 配置、寄存器訪問等相關服務"
sc config "Verity Platform Device Service" start= AUTO
sc start "Verity Platform Device Service"
pause
注1:"Verity Platform Device Service" 為服務名;
注2:WindowsService_HardwareDevice.exe 為自己創建的用於承載 WCF 服務的的 Windows服務的安裝程序,創建方式如下:
注3:pause 的作用為 .bat 運行完不退出,以查看運行結果(也可使用 @cmd.exe)。
- 以管理員身份運行 ServiceInstall.bat 完成 Windows 服務安裝。
2. 卸載
- 新建文本文件,重命名為 ServiceUninstall.bat,將 ServiceUninstall.bat 的內容替換為:
sc stop "Verity Platform Device Service"
sc delete "Verity Platform Device Service" binPath= "%~dp0WindowsService_HardwareDevice.exe"
@cmd.exe
- 以管理員身份運行 ServiceUninstall.bat 完成 Windows 服務卸載。