Microsoft provide the command line tool for managing the windows services: sc

for example, if you want to add a windows service: sc create {service name} binPath= {c:\test.exe} {options}

One thing to notice: there’s an empty space between the “binPath” and the real path, you cannot skip this space.