Help with simple code example
Help with simple code example
I am a new registered user and bought the component for a simple task. I don't need a scheduling wizard, but want to be able to create (and later on, edit) a task that calls an external .EXE file once a week in the middle of the night (i.e. 1:00 AM) from within my Delphi app. Can someone send me a simple example of the above code? Thanks for the help ...
Mark
Mark
The requested demo is available at:
http://www.sicomponents.com/soft/TaskSc ... unDemo.zip
http://www.sicomponents.com/soft/TaskSc ... unDemo.zip
Thanks for the help!
Thanks for the demo. I got my code built and it works great!
Mark
Mark
Example application
The example application compiles file, but the Windows scheduler won't run it. It gives the status as "Could not start". I have tried with two applications of my own using your example and they have the same problem. One other point, in my applications, I want the scheduler to restart the calling application at the designated time.
There could be one of the following reasons for this:
1. You've specified wrong account name and password
2. It is impossible to find the path to executable. In this example there is used TaskItem.ApplicationName := Application.ExeName; Please check that ApplicationName contains the FULL path to executable.
Hope this helps.
1. You've specified wrong account name and password
2. It is impossible to find the path to executable. In this example there is used TaskItem.ApplicationName := Application.ExeName; Please check that ApplicationName contains the FULL path to executable.
Hope this helps.
Simple example
What account name and password should I use? The account and password for logging onto the computer at start up? There isn't one on this machine.
Mark
Mark
Simple example
Is there an API / function call to get the Account Name and Password programmatically? It would make my life easier. I did do some testing and specifying the account name and password seemed to fix the problem. Thanks for the help ...
Mark
Mark
Hello,
The Windows API function "GetUserName" retrieves the name of the user currently logged onto the system. This function might simplify setting the task paramaters a little but the password anyway should be typed by the user.
Another way is running task under "SYSTEM" account. In this case BOTH AccountName and Password should be empty and the task should NOT have the flag tfRunOnlyIfLoggedOn. Example:
...
if (Trim(Accnt) = EmptyStr) and (Trim(Pwd) = EmptyStr) then
FTask.Flags := FTask.Flags - [tfRunOnlyIfLoggedOn]
else
FTask.Flags := FTask.Flags + [tfRunOnlyIfLoggedOn];
FTask.SetAccountInformation(Trim(Accnt), Trim(Pwd));
...
Note, scheduling tasks under the "SYSTEM" account has some limitations. For example, a task running under SYSTEM does not allow interaction with the logged user (that is no message boxes, prompts, any dialogs).
The Windows API function "GetUserName" retrieves the name of the user currently logged onto the system. This function might simplify setting the task paramaters a little but the password anyway should be typed by the user.
Another way is running task under "SYSTEM" account. In this case BOTH AccountName and Password should be empty and the task should NOT have the flag tfRunOnlyIfLoggedOn. Example:
...
if (Trim(Accnt) = EmptyStr) and (Trim(Pwd) = EmptyStr) then
FTask.Flags := FTask.Flags - [tfRunOnlyIfLoggedOn]
else
FTask.Flags := FTask.Flags + [tfRunOnlyIfLoggedOn];
FTask.SetAccountInformation(Trim(Accnt), Trim(Pwd));
...
Note, scheduling tasks under the "SYSTEM" account has some limitations. For example, a task running under SYSTEM does not allow interaction with the logged user (that is no message boxes, prompts, any dialogs).
System account
I'm still having problems getting my project to work. I am making an application that automatically sends a file as an attachment to an e-mail address. I want this file to be scheduled to be sent once a week. I have tried using the System account without any luck. When I manually try to use the system account in the XP task scheduler, it says my program is running with nothing showing on the screen or being sent. Unfortunately, I can't use the administrator account in Window XP since many people (including myself) don't remember the password they use with their login. Norton Antivirus seems to have found a way to use the administrator account without the user providing a password. Any suggestions on how to fix my problem?
Mark
Mark
There are 2 options:
1) use the SYSTEM account (empty accountname and password). In this case however, the application indeed does not show any dialogs. Therefore you will need to redesign your applcaition so it does not require any interaction with user.
2) You can use any account or create a special account for this task, but set the flagThen the task will run when any user is logged on. However, if the task's account is different from the current user, the last one still won't be able to interact with program.
P.S. You tried to run a task under system account in the XP task scheduler and the email was not sent. It is possible that Norton Internet Secutity firewall just didn't allow the email sending.
1) use the SYSTEM account (empty accountname and password). In this case however, the application indeed does not show any dialogs. Therefore you will need to redesign your applcaition so it does not require any interaction with user.
2) You can use any account or create a special account for this task, but set the flag
Code: Select all
FTask.Flags := FTask.Flags - [tfRunOnlyIfLoggedOn];
P.S. You tried to run a task under system account in the XP task scheduler and the email was not sent. It is possible that Norton Internet Secutity firewall just didn't allow the email sending.
System account
I got my application running now with the System account; however, I have a problem with my button to edit the schedule using the TTaskPropertiesDialog component. My problem is that the changes made using the TTaskPropertiesDialog are not being saved / applied to the Windows Task Scheduler.
My onClick code for the Edit Schedule button is:
TaskDialog1.TaskName := 'MyName';
TaskDialog1.Execute;
Is the Execute method supposed to save the changes? What do I need to do differently?
My onClick code for the Edit Schedule button is:
TaskDialog1.TaskName := 'MyName';
TaskDialog1.Execute;
Is the Execute method supposed to save the changes? What do I need to do differently?
System account
Is there a way to set the Run As property / field in the Windows XP Task Scheduler programmatically with your components. To make the system account work, you need to specify the Run As field as "System".