標籤:windows project 服務 格式 util png mic index div
轉自:http://www.cnblogs.com/sorex/archive/2012/05/16/2502001.html
1)建立Windows service項目
二、建立服務安裝程式
1)添加安裝程式
之後我們可以看到,自動為我們建立了ProjectInstaller.cs以及2個安裝的組件。
2)修改安裝服務名
右鍵serviceInsraller1,選擇屬性,將ServiceName的值改為ServiceTest。
3)修改安裝許可權
右鍵serviceProcessInsraller1,選擇屬性,將Account的值改為LocalSystem。
三、寫入服務代碼
1)開啟ServiceTest代碼
右鍵ServiceTest,選擇查看代碼。
2)寫入Service邏輯
四、建立安裝指令碼(在WindowsServiceTest.exe所在的目錄下建立)
在項目中添加2個檔案如下(必須是ANSI或者UTF-8無BOM格式):
1)安裝指令碼Install.bat
%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil.exe D:\huiyishi\WindowsServiceTest\WindowsServiceTest\bin\Debug\WindowsServiceTest.exe2)卸載指令碼Uninstall.bat
%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil.exe /u D:\huiyishi\WindowsServiceTest\WindowsServiceTest\bin\Debug\WindowsServiceTest.exe
c#建立Windows service (Windows 服務)基礎教程