Enter NSSM, the Non-Sucking Service Manager.
A little utility that can either be used from command-line or via a GUI (but still invoked from command-line). It (obviously) allows you to add, edit and remove Windows services. It comes with many useful features, notably the best ones to me are:
- redirection of stdout and stderr to log files,
- the variable grace period for shutdowns (your application might take a while to wind down properly) and
- the ability to automatically restart the service, but only if it hasn’t been running for less than X msecs (early crashes are more likely due to a misconfiguration or such things).
Here is a screenshot of the user interface, taken from the project’s website: