bat文件 內容為
cd C:\Windows\Microsoft.NET\Framework\v4.0.30319\
InstallUtil.exe
InstallUtil F:\Windows Services\WindowsServiceTest\WindowsServiceTest_1_0_0_0\WindowsServiceTest.exe
Net Start Service1
pause
其中C:\Windows\Microsoft.NET\Framework\v4.0.30319\為installutil的路徑
WindowsServiceTest.exe為Windows Service服務的應用程序,教程
Service1為服務名
ps:.bat與WindowsServiceTest.exe在同一路徑
【出現問題】
在初始化安裝時發生異常:
System.IO.FileNotFoundException: 未能加載文件或程序集“file:///F:\Windows”或它
的某一個依賴項。系統找不到指定的文件。。
原因:
路徑中出現了空格
解決方案:文件放到沒有空格的路徑
eg:
F:\WindowsServiceTest_1_0_0_0\WindowsServiceTest.exe