Can't create event without UserName and Password

This forum is designated to discuss SiComponents Scheduling Agent.
Post Reply
NickN
Posts: 6
Joined: Sun Oct 22, 2006 3:34 pm

Can't create event without UserName and Password

Post by NickN »

I'm new, have tried your demo but can't even get demo to work without UserName and Password. My intention was to use this component to set events though my software using this component (advertised feature being I would not need to use timer resources). This is a snipet of your demo... which fails to do anything unless UserName and Password is also supplied. Can you provide modified code that will work from my application... for example: to run another application once a day, on a computer which I know nothing about (which is the normal case). Thanks. Here's your current code from your demo:

procedure TMainForm.Createtasktorunevery10minutesfor24hours1Click(
Sender: TObject);
var
TriggerDetails: TTriggerDetails;
ANow: TDateTime;
S: string;
begin
if not odExecutable.Execute then Exit;
with Scheduler.CreateNewItem(Format('New task %d', [GetTickCount])) do
begin
ApplicationName := odExecutable.FileName;
Triggers.Add;
Triggers[0].TriggerType := ttDaily;
// Modern Delphi can use this code
// Triggers[0].StartTime := IncHour(Now, 1);
// Delphi 4 compatible code
ANow := Now;
Triggers[0].StartTime := ((ANow * 24) + 1) / 24;
Triggers[0].BeginDate := Date;
Triggers[0].EndDate := Date + 30; // not needed!
Triggers[0].HasEndDate := False;
TriggerDetails.Daily.DaysInterval := 1;
Triggers[0].Details := TriggerDetails; // trigger details must be changed only this way
Triggers[0].Duration := 24 * 60; // run for 24 hours
Triggers[0].Interval := 10; // 10 minutes
// could be used UpdateTriggers and Save
Triggers.UpdateTriggers;
Save;
// or just Deactivate(True)
//Deactivate(True);
end;
acRefresh.Execute;
end;
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

Hello,

To setup task without user name and password you need to call SetAccountInformation("", "") method. Did you use the trial version available for download from our web site? The exact text of this demo in the latest package looks like:

Code: Select all

procedure TMainForm.Createtasktorunevery10minutesfor24hours1Click(
  Sender: TObject);
var
   TriggerDetails: TTriggerDetails;
   ANow: TDateTime;
   S: string;
begin
  if not odExecutable.Execute then Exit;
  with Scheduler.CreateNewItem(Format('New task %d', [GetTickCount])) do
  begin
    ApplicationName := odExecutable.FileName;
    Triggers.Add;
    Triggers[0].TriggerType := ttDaily;
    // Modern Delphi can use this code
//    Triggers[0].StartTime := IncHour(Now, 1);
    // Delphi 4 compatible code
    ANow := Now;
    Triggers[0].StartTime := ((ANow * 24) + 1) / 24;
    Triggers[0].BeginDate := Date;
    Triggers[0].EndDate := Date + 30; // not needed!
    Triggers[0].HasEndDate := False;
    TriggerDetails.Daily.DaysInterval := 1;
    Triggers[0].Details := TriggerDetails; // trigger details must be changed only this way
    Triggers[0].Duration := 24 * 60; // run for 24 hours
    Triggers[0].Interval := 10; // 10 minutes
    // could be used UpdateTriggers and Save
    Triggers.UpdateTriggers;
     // to set-up a task for user w/o password
      // use the code below
      {Flags := Flags + [tfRunOnlyIfLoggedOn];
      SetAccountInformation(GetOSUser, '');}
    Save;
    // or just Deactivate(True)
    //Deactivate(True);
  end;
  acRefresh.Execute;
end;
Please take a note to the commented code between Triggers.UpdateTriggers; and Save;.
Please let me know if this helps.
Best regards,
Igor Siticov.
NickN
Posts: 6
Joined: Sun Oct 22, 2006 3:34 pm

Post by NickN »

Igor, thanks for the quck reply... but it does not work still. I use the Quick Demo, select for every 10 minutes to run Notepad, use the code "SetAccountInformation('', '');" and am using version 1.0.4 of the component source code.

After 10 minutes "Next Run Time" column in the demo application updates as if Notepad did run (but it did not) and shows the next 10 minutes. So, the timers are working but nothing really happens.

Since the source you supplied for the demo is different from the source I have when I registered (about 3 weeks ago), I wonder if maybe I just don't have th correct demo AND source code.

Could you please email me the correct registered version (including demo) so I can update what I received and then I can try again.

Do you have my registration info?
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

Nick,

Actually, there were just few changes made in the demo projects and may be the source code differs a little. We're planning to release updated version for Scheduling Agent in few days. So it will include updated sample projects. Please let me know if you wait for 1.0.5 or still need 1.0.4.
Best regards,
Igor Siticov.
NickN
Posts: 6
Joined: Sun Oct 22, 2006 3:34 pm

Post by NickN »

Oh, I can wait. And thank you for all the quick replies. Hope new version handles being able to create tasks without UserName & Password.

Regards.
NickN
Posts: 6
Joined: Sun Oct 22, 2006 3:34 pm

Tried new version 1.0.5

Post by NickN »

Hi Igor, just to update my previous request about UserName and Password... I tried the 1.0.5 version using the Demo program and now it is working correctly when _NOT_ entering a password. I also modified several parameters and tested again -- and again, it is working properly using delphi 7 and using the Demo program.

Big thanks and best regards.
Post Reply