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
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