using system;install.text裡面放如下**:using system.collections.generic;
using system.componentmodel;
using system.data;
using system.diagnostics;
using system.linq;
using system.serviceprocess;
using system.text;
using system.threading.tasks;
using system.timers;
namespace windowsservice1
protected override void onstart(string args)
catch (system.exception ex)
}public void chksvr(object source, elapsedeventargs e)
catch (exception ex)
}public void sendmessahe()
catch (exception ex)
}public void writelog(string read)
protected override void onstop()
}}在安裝程式中選中【serviceprocessinstaller1】,檢視其屬性,將【account】值改為【localsystem】。
在安裝程式中選中【serviceinstaller1】,檢視其屬性,將【servicename】值改為你想要的服務名稱。
在目錄【c:\windows\microsoft.net\framework】中找到程式對應的.net版本 找到【installutil.exe】 複製到 專案 bin/debug 下
%systemroot%\microsoft.net\framework\v4.0.30319\installutil.exe d:\c#\fanso2o_monitoringactivity\fanso2o_monitoringactivity\bin\debug\fanso2o_monitoringactivity.exe
net start fanso2o_monitoringactivity
sc config fanso2o_monitoringactivity start= auto
pause
uninstall.text裡面放如下**:
%systemroot%\microsoft.net\framework\v4.0.30319\installutil.exe /u d:\c#\fanso2o_monitoringactivity\fanso2o_monitoringactivity\bin\debug\fanso2o_monitoringactivity.exe
pause
無法開啟計算機「.」上的服務控制管理器。此操作可能需要其他特權。:使用管理員許可權開啟cmd
使用C 建立windows服務
前言 說幹就幹!開發環境 作業系統 windows 10 x64 開發環境 vs2017 程式語言 c net版本 net framework 4.5 目標平台 x86 windows service簡介 乙個windows服務程式是在windows作業系統下能完成特定功能的可執行的應用程式。win...
windows服務建立
以下是安裝命令 啟動服務命令 停止服務命令 解除安裝服務命令 安裝命令 c windowservice installutil.exe c windowservice organizclientsocketservice.exe 啟動服務命令 net start 搜才organiz客戶端資料同步服務...
使用C 建立windows服務程式
建立windows服務專案 一 建立服務 1 檔案 新建 專案 windows桌面 windows服務,修改你要的專案名稱。我這不改名,仍叫windowsservice1,確定。2 其中的program.cs檔案是入口,service1.cs是服務檔案,所有的邏輯都在這。service1.cs包含兩...