ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Standard functions / Windows functions / Windows Scheduler functions
  • Overview
  • Details of the TriggerScheduledTask structure
  • Variables that can be used according to the type of task
  • Example
  • Example for adding a task
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Overview
The TriggerScheduledTask structure is used to define all the events that will define the execution of a task. The variables of this structure are reinitialized by SchedulerReset.
This structure must be filled before using SchedulerAddTrigger or SchedulerAddTask.
The default trigger is set to every day at 9:00 AM.
Details of the TriggerScheduledTask structure
The parameters to be specified in the TriggerScheduledTask structure depend on the type of trigger defined for the scheduled task.
A scheduled task can be: daily, weekly, monthly, executed once only, executed at startup, executed when the system is idle.
The type of trigger defined for the scheduled task is determined by the TriggerScheduledTask.Type variable. Below are the details of this and all the other variables of the TriggerScheduledTask structure.
TriggerScheduledTask.BeginDateDate
Date from which the task can be performed. By default, this date corresponds to the creation date of the task.
Associated task type: Weekly task, monthly task and daily task.
TriggerScheduledTask.CaptionCharacter string
Text of the trigger (event that starts the scheduled task).
This variable is read-only and it is updated when a trigger is read (SchedulerTriggerProperties)
TriggerScheduledTask.DateDate
Date when the task will be run.
Associated task type: One-time task.
TriggerScheduledTask.DayInteger
The task will be performed on this day of the month. Can correspond to:
  • the number of a day (between 1 and 31)
  • the name of a day + its position in the monthExample: 1st Monday of the month: htMonday + htFirst

The available values are:
  • schedMonday, schedTuesday, schedWednesday, schedThursday, schedFriday, schedSaturday, schedSunday
  • schedFirst, schedSecond, schedThird, schedFourth, schedLast. The task is performed every 1st of each month by default.

Associated task type: Monthly task
TriggerScheduledTask.DayOfWeekInteger
The task will be performed on this day of the week. Corresponds to the name of a day + its position in the month
Example: 1st Monday of the month: htMonday + htFirst
Available values are: htMonday, htTuesday, htWednesday, htThursday, htFriday, htSaturday, htSunday
The task is performed every Monday by default.
Associated task type: Weekly task
TriggerScheduledTask.EndDateDate
Date from which the task will no longer be performed. To specify no end date, use an empty string.
No end date is specified by default.
Associated task type: Weekly task, monthly task and daily task.
TriggerScheduledTask.ForcedStopBoolean.
If this parameter is set to True, stops the task currently run when the repeat duration is exceeded.
This variable is set to False by default.
Associated task type: Weekly task, monthly task, daily task and once-only task.
TriggerScheduledTask.IdleWaitInteger in minutes
Amount of idle time required before performing the task. This duration is set to 10 minutes by default.
Associated task type: Execute when system is idle
TriggerScheduledTask.IntervalInteger
Number of days or number of weeks between each execution. This variable is set to 1 by default.
Associated task type: Weekly task, daily task.
TriggerScheduledTask.MonthInteger
The task will be performed during this month. Corresponds to one or more month names: htJanuary, htFebruary, htMarch, htApril, htMay, htJune, htJuly, htAugust, htSeptember, htOctober, htNovember, htDecember.
Example: htJanuary + htAugust: performs the task in January and August.
The task is performed every month by default.
Associated task type: Monthly task
TriggerScheduledTask.RepeatDurationInteger in minutes.
The task will be repeated during the specified duration. This duration is set to 60 minutes by default.
Associated task type: Weekly task, monthly task and daily task.
TriggerScheduledTask.RepeatIntervalInteger in minutes
The task will be repeated during this interval (0 if the task must be performed once). The task is not repeated by default.
Associated task type: Weekly task, monthly task, daily task and once-only task.
TriggerScheduledTask.TimeTime
Time when the task will be run. This variable is set to 9:00 AM by default
Associated task type: Weekly task, monthly task, daily task and once-only task.
TriggerScheduledTask.TypeThis variable can take one of the following values:
schedDaily
(default value)
Run on a daily basis
schedIdleExecuted when the system is idle.
schedLogonExecuted when starting a session.
schedMonthlyRun on a monthly basis.
schedOnceRun once.
schedSystemStartRun at system startup.
schedWeeklyRun on a weekly basis.
Variables that can be used according to the type of task
The table below presents the variables that can be used according to the type of task:
schedDailyTriggerScheduledTask.Time
TriggerScheduledTask.Interval
TriggerScheduledTask.BeginDate
TriggerScheduledTask.EndDate
TriggerScheduledTask.RepeatInterval
TriggerScheduledTask.RepeatDuration
TriggerScheduledTask.ForcedStop
schedIdleNo specific variable
schedLogonNo specific variable
schedMonthlyTriggerScheduledTask.Time
TriggerScheduledTask.Day
TriggerScheduledTask.Month
TriggerScheduledTask.BeginDate
TriggerScheduledTask.EndDate
TriggerScheduledTask.RepeatInterval
TriggerScheduledTask.RepeatDuration
TriggerScheduledTask.ForcedStop
schedOnceTriggerScheduledTask.Time
TriggerScheduledTask.Date
TriggerScheduledTask.RepeatInterval
TriggerScheduledTask.RepeatDuration
TriggerScheduledTask.ForcedStop
schedSystemStartNo specific variable
schedWeeklyTriggerScheduledTask.Time
TriggerScheduledTask.Interval
TriggerScheduledTask.BeginDate
TriggerScheduledTask.EndDate
TriggerScheduledTask.RepeatInterval
TriggerScheduledTask.RepeatDuration
TriggerScheduledTask.ForcedStop
Example

Example for adding a task

SchedulerReset()
// Création de la tache planifiée
ScheduledTask.Application = "MonExécutable.exe"
ScheduledTask.CommandLine = ReqToutSurUneBackup.Nom
ScheduledTask.SystemOn = True
ScheduledTask.Comment = "Programme WINDEV"

// Création des horaires de la tâche planifiée
// SEL_TypeSauvegarde est un sélecteur proposant 
// une sauvegarde unique, hebdomadaire, mensuelle ...

TriggerScheduledTask.Type = SEL_TypeSauvegarde

// Date d'exécution de la sauvegarde unique
IF SEL_TypeSauvegarde = schedDaily THEN
	IF SAI_DateUnique <> "" THEN
		IF SAI_HoraireUnique <> "" THEN
			TriggerScheduledTask.Date = SAI_DateUnique 
			TriggerScheduledTask.Time = SAI_HoraireUnique
		ELSE
			Info("Vous devez saisir une heure valide de sauvegarde.")
			RETURN
		END
	ELSE
		Info("Vous devez saisir une date valide de sauvegarde.")
		RETURN
	END
END
// Sauvegarde Chaque mois
IF SEL_TypeSauvegarde = schedMonthly THEN
	IF SAI_HoraireUnique <> "" THEN
		TriggerScheduledTask.Day = SEL_JourDuMois
		TriggerScheduledTask.Time = SAI_HoraireUnique
	ELSE
		Info("Vous devez saisir une heure valide de sauvegarde.")
		RETURN
	END
END
// Sauvegarde chaque semaine
IF SEL_TypeSauvegarde = schedWeekly THEN
	IF SAI_HoraireUnique <> "" THEN
		TriggerScheduledTask.DayOfWeek = SEL_JourDeLaSemaine
		TriggerScheduledTask.Time = SAI_HoraireUnique
	ELSE
		Info("Vous devez saisir une heure valide de sauvegarde.")
		RETURN
	END
END
IF NOT SchedulerAddTask("MaTache") THEN 
	Error(ErrorInfo())
ELSE
	Info("L'application a été ajoutée au gestionnaire de tâches de Windows")
END
Minimum version required
  • Version 10
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/28/2025

Send a report | Local help