Problem running a scheduled service

M

Michael Groeger

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
 
M

Michael Groeger

Hi,

sorry, my fault. The service was not running as I tried to stop it.

Regards,
Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top