c# windows service(服务)
//安装
%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil.exe WindowsServiceTest.exe
//卸载
%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil.exe -u WindowsServiceTest.exe
具体步骤参考:
http://www.cnblogs.com/sorex/archive/2012/05/16/2502001.html
死循环的程序:
protected override void OnStart(string[] args) { Task.Run(()=> { run(); }); } public void run() { while (true) { using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\log.txt", true)) { sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "Start."); } Thread.Sleep(2000); } }
@echo off %SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil.exe "%~dp0\DeLoadServer.exe" echo "安装成功" Net Start DeLoadServer sc config DeLoadServer start= auto pause

浙公网安备 33010602011771号