Windows服务开发学习

开发服务

选择serviceProcessInstaller1,account选择localsystem

Windows服务开发学习

选择serviceInstaller1,description为windows服务运行时候的描述信息,ServiceName为运行在服务里面的服务名称

Windows服务开发学习
注意:服务运行的路径为C:\Windows\System32,获取程序运行路径使用AppDomain.CurrentDomain.BaseDirectory;

安装服务

安装服务bat脚本

%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil.exe E:\wcfService\WinServiceWCF.exe
pause

卸载服务bat脚本

%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil.exe /u E:\wcfService\WinServiceWCF.exe
pause