How to manage ServiceHost in Windows service from a Winforms admin tool?

292 Views Asked by At

I have a Windows service that create more than one instance of ServiceHost...

I want to be able to manage those ServiceHosts through an external winforms admin tool, so I can open and close each of the ServiceHost from a UI.

What are my options (apart from wrapping each ServiceHost with process)?

2

There are 2 best solutions below

0
On

I would expose another (WCF) service from your (Windows) service, exposing operations to manipulate the service hosts in that process.

0
On

You can register one service multiple times with different start parameter and name. Such configuration could be more robust.

sc.exe create Service_1 binPath= "C:\bin\myserv.exe -run=serviceFirst" DisplayName = "Server 1"

sc.exe create Service_2 binPath= "C:\bin\myserv.exe -run=serviceSecond" DisplayName = "Server 2"