Say I have a third party Application that does background work, but prints out all errors and messages to the console. This means, that currently, we have to keep a user logged on to the server, and restart the application (double-click) every time we reboot.
Not so very cool.
I was kind of sure, that there was an easy way to do this - a generic service wrapper, that can be configured with a log file for stdout
and stderr
.
I did check svchost.exe
, but according to this site, its only for DLL stuff. Pity.
EDIT: The application needs to be started from a batch file. FireDaemon seems to do the trick, but I think it is a bit overkill, for something that can be done in <10 lines of python code... Oh well, Not Invented Here...
You can also open Services from the Command Prompt or PowerShell. Type the command services. msc and press Enter on your keyboard.
A Windows Service may launch a UI application but this application will never be displayed on the currently logged-in user's desktop. This tip shows how to launch a UI application from a Windows Service by using the Windows API.
Check out srvany.exe
from the Resource Kit. This will let run anything as a service.
You can pass parameters in the service definition to your executable via srvany.exe
so you could run a batch file as a service by seting the registry as follows:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyService\Parameters]
"Application"="C:\\Windows\\System32\\cmd.exe"
"AppParameters"="/C C:\\My\\Batch\\Script.cmd"
"AppDirectory"="C:\\My\\Batch"
Note: if you set up these keys in RegEdit
rather than using a file you only need single backslashes in the values.
I'd recommend NSSM: The Non-Sucking Service Manager.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With