使用winsw给Win10添加服务

平台:win10

问题:把自启动程序添加为服务

解决过程:

一直习惯了用CLaunch启动各类应用程序,但近期不知怎么回事,每次进入系统CLaunch都不会自动启动。重装后也好用没几天。明明计划任务里CLaunch的启动设置很正常的。

于是干脆把ClAdmin.exe设置成服务好了。

使用WinSW的过程如下。

1、去https://github.com/kohsuke/winsw/releases下载WinSW的主程序WinSW.NET4.exe和配置文件sample-minimal.xml

2、把WinSW.NET4.exesample-minimal.xml拷贝到CLaunch的安装路径D:\Program Files\CLaunch下。给WinSW.NET4.exe改名为CLauncher.exe,sample-minimal.xml改名为CLauncher.xml。

3、用Notepad++(或者notepad2)打开CLauncher.xml,进行部分设置如下

 

<service>

<!-- ID of the service. It should be unique across the Windows system-->
<id>CLaunch</id>
<!-- Display name of the service -->
<name>CLaunch</name>
<!-- Service description -->
<description>CLaunch是个用于增强桌面功能的快速启动软件,本服务由Windows Service Wrapper(WinSW)建立。</description>

<!-- Path to the executable, which should be started -->
<executable>D:\Program Files\CLaunch\ClAdmin.exe</executable>

 

 

 

</service>

 

4、用管理员权限打开CMD,定位到D:\Program Files\CLaunch下,输入CLauncher.exe install,回车,提示“Installing the service with id 'CLaunch'”服务安装成功。运行services.msc打开服务管理窗口,找到CLaunch服务,跟普通服务一样可以设置自动、手动、禁用,启用停用,发现可执行路径为"D:\Program Files\CLaunch\CLauncher.exe"。显然CLaunch.exe的启动是由WinSW中转了下。

5、想卸载该服务,可以重复4步骤,输入CLauncher.exe uninstall

 

posted @ 2020-02-24 09:53  mahocon  阅读(5734)  评论(0编辑  收藏  举报