471,315 Members | 2,108 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,315 software developers and data experts.

Problem running a scheduled service

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
Dec 14 '05 #1
1 1010
Hi,

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

Regards,
Michael
"Michael Groeger" <go*********@web.de> schrieb im Newsbeitrag
news:OG*************@TK2MSFTNGP12.phx.gbl...
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

Dec 14 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Harlin Seritt | last post: by
2 posts views Thread by WKC | last post: by
1 post views Thread by Michael Groeger | last post: by
8 posts views Thread by Dan Pavel | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.