Reputation: 528
I've implemented a Windows Service with custom commands overriding OnCustomCommand method.
I can access these custom commands from another .net application with:
ServiceController Controller = new ServiceController("MyWindowsService");
if (Controller.Status == ServiceControllerStatus.Running)
{
Controller.ExecuteCommand(128);
}
But, can I access these custom commands from the command line (cmd) the same way I can start/stop/... the service?
EDIT: (Without creating a middleware application to handle the service, just with standard tools)
Upvotes: 2
Views: 3501
Reputation: 175976
You can use the Service Control command line tool sc
> sc control MyWindowsService 128
(Under the hood everything is using Win32's ControlService
API.)
Upvotes: 4