Hi NG,
I have written a service which should start at certain time in the morning
and stop at a certain time in the evening. For this, I added the following
to the Main() method of the service:
public void Main(string[] args)
{
// [...]
if (args.Length == 1)
{
if (args[0] == "-startsvc")
{
ServiceController ctrl = new ServiceController("MyService",
".");
ctrl.Start();
}
else if (args[0] == "-stopsvc")
{
ServiceController ctrl = new ServiceController("MyService",
".");
ctrl.Stop();
}
// [...]
}
// [...]
}
I use Scheduled Tasks to run and stop the service and certain times.
However, when Windows (2000) is locked and the the service should start or
stop, the service cannot but instead throws an
System.InvalidOperationException. Can somebody help?
Regards,
Michael
Michael Groeger - 14 Dec 2005 11:09 GMT
Hi,
sorry, my fault. The service was not running as I tried to stop it.
Regards,
Michael
> Hi NG,
>
[quoted text clipped - 31 lines]
> Regards,
> Michael