使用C#代码安装、卸载、启动、停止Service

maruihan 31 0 RAR 2019-09-06 11:09:28

在需要安装的项目文件中添加WindowsService项目的引用,在程序集中获取Service.exe的路径,使用AssemblyInstaller类对service进行安装。在安装时,使用ServiceController判定服务是否存在,如果已存在该service,则先卸载,再重新安装。在卸载时,使用ServiceController判断Service是否在运行,如果在运行,则先停止该服务,然后再卸载

用户评论
请输入评论内容
评分:
Generic placeholder image 卡了网匿名网友 2019-09-06 11:09:28

资源不错,很有参考价值

Generic placeholder image 卡了网匿名网友 2019-09-06 11:09:28

好久没有做过安装包了,好多东西忘记,今天看了一下,做起来还是挺方便的。

Generic placeholder image 卡了网匿名网友 2019-09-06 11:09:28

代码一般,没有特别大的借鉴价值

Generic placeholder image 卡了网匿名网友 2019-09-06 11:09:28

好像不兼容win8,试了几次报错。

Generic placeholder image 卡了网匿名网友 2019-09-06 11:09:28

资源还不错,只是就看了一下源码。