Add a Startup Program on Windows - WinSW

给 Windows 添加自启动程序,让程序开机启动

We are going to use winsw to add a program called dosomething to Windows service, and the program will be started automatically when the Windows is started(before a user logged in).

Suppose our working directory is D:\dosomething, and our main program is D:\dosomething\dosomething

Prepare the winsw executable file

Download the winsw exe file called WinSW, and put it into the working directory.

Create a confile file for winsw

Create a file winsw.xml and put it into the working directory.

cat winsw.xml

    <description>dosomething client</description>
    <arguments>-c dosomething.ini</arguments>

Register the service

open CMD, and change directory into the working directory:

cd dosomething

Register the service

WinSW.exe install winsw.xml

By now, the dosomething service is not started yet. We should start it manually in the service list.

Restart the Windows to test

Restart the Windows to see the dosomething process and its tcp/udp port is started.