Task Scheduler service disabled

This forum is designated to discuss SiComponents Scheduling Agent.
Post Reply
lterb
Posts: 4
Joined: Tue Jan 09, 2007 2:27 am

Task Scheduler service disabled

Post by lterb »

Please forgive my English (I am using an online translator) and my doubt, I am not a professional developer, like all of you. :oops:

I wrote a simple application, using Delphi 7 Personal and Scheduling Agent v1.0.5 (registered), and it works well.

But if the Task Scheduler service in Windows XP SP2 is disabled and stopped, the application does not start (the Demo of Scheduling Agent does not start either), and return the error "Task Scheduler service is not running".

I have made a modification in saTask.pas, procedure TTaskScheduler.SetActive:

begin
// if (Value) then -> old line
if (Value) and (StartScheduler) then // -> modification
Open
else
Close;
end;

With that modification, the application starts when the Task Scheduler service is disabled, so a custom error message can be shown if the user try to use the "Edit Task" function and the other functions of the application can be used.

My doubt is: this goes to cause some malfunction in Scheduling Agent?

Thank you in advanced!
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

Hello,

Actually, StartScheduler will start the Scheduler service and this is why your application started to work. I would recommend you the following:
1. Set Active property of TaskScheduler component to False at design-time.
2. In OnCreate event of your form activate it using

Code: Select all

try
  TaskScheduler1.Active := True;
  except
... Add here some actions in case Scheduler was unable to start.
  end;
or

Code: Select all

if TaskScheduler1.SchedulerServiceRunning then
    TaskScheduler1.Active := True
  else
  begin
    if TaskScheduler1.StartScheduler then
      TaskScheduler1.Active := True
    else
      ShowMessage('Unable to start Scheduler service!');
  end;
Please note: this might cause some problems on some users who "doesn't like@ your app start Scheduler Service. So it may be worth to ask them after checking the return of SchedulerServiceRunning method.
Hope this helps.
Best regards,
Igor Siticov.
lterb
Posts: 4
Joined: Tue Jan 09, 2007 2:27 am

Post by lterb »

Thank you very much for your fast response!

I have tested your recomendation, but it does not work, the application does not initialize, it shows an error message, and another, and another, and finally ends the messages, but does not start at all.
The demo of Scheduling Agent shows two error messages and does not start either.

Sorry, but is the StartScheduler capable of initialize the Task Scheduler service if it is not only stopped, but also disabled?
I am asking that because if it is, I will have to discovery why in my tests it is not.

Thank you again.
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

StartScheduler starts scheduler only if it is stopped. If service is disabled I guess it won't be able to start it. Sorry.
Best regards,
Igor Siticov.
lterb
Posts: 4
Joined: Tue Jan 09, 2007 2:27 am

Post by lterb »

It's ok, it's not a problem, the Scheduling Agent is a fantastic component! :D

Actually, I would only like to know if this small modification in saTask.pas,
which I described in my first post, will cause unexpected problems in
Scheduling Agent. What do you think about this?

Please excuse me to disturb you again with the same question!
Thank you.
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

Hello,

No, your modification shouldn't cause any problem except it will be deleted in case of future upgrades. So just please be sure to record them and apply once you download updated versions from us.
Best regards,
Igor Siticov.
lterb
Posts: 4
Joined: Tue Jan 09, 2007 2:27 am

Post by lterb »

I will do that.

Thank you very much!
Post Reply