Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interacting with running Windows Service?

How do I change settings of Windows Service while it's running?

Let's say I process files from one directory to another. I'd like to be able to declare the output and operations for next files (while the service is running). Would be perfect if I could edit it remotely via website (SQL tables or maybe XML/TXT files).

Is it at all possible without restarting service? Could I simply write inside service "for every file read operations and output from settings file"?

I'd rather avoid for now Windows Communication Foundation.

like image 415
yosh Avatar asked Dec 27 '25 16:12

yosh


2 Answers

Assuming you also wrote the Windows Service, you could send a custom command to the service. From the controller side, you use ServiceController.ExecuteCommand() to send the command. On the service class, you override ServiceBase.OnCustomCommand() to process the commands.

This will only help you trigger an action, however. You will still have to use an external method (e.g. shared configuration file) to convey the details of the action.

like image 178
seairth Avatar answered Dec 30 '25 06:12

seairth


yosh - the two options you proposed would work, the service could read a file settings.xml repeatedly before it processes a folder. You could tinker with that remotely without restarting the service.

like image 24
phoenixAZ Avatar answered Dec 30 '25 06:12

phoenixAZ



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!