文章出處
文章列表
//安裝
%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
文章列表
全站熱搜