AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Funciones estándar / Funciones de Windows / Funciones del programador de Windows
  • Overview
  • ScheduledTask structure
  • Example
  • Example for adding a task
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
Overview
The ScheduledTask structure is used to define the characteristics of a scheduled task. The variables of this structure are reinitialized by SchedulerReset.
Note: When creating a new task, the structure PlannedTask is used, as well as the TriggerScheduledTask structure.
ScheduledTask structure
The different variables of ScheduledTask structure are as follows:
ScheduledTask.ApplicationCharacter string.
Name and path of program to run.
ScheduledTask.StopOnIdleEndBoolean.
True if the task must be stopped as soon as the system resumes an activity.
This variable is set to False by default.
ScheduledTask.StopOnBatteriesBoolean.
True if the task must be stopped when the computer switches to battery power.
This variable is set to True by default.
ScheduledTask.ErrorCodeInteger.
Last error code returned by the task (0 if the task was successfully completed or if the program has never been started).
This variable is read-only and is updated with SchedulerTaskProperties.
ScheduledTask.CommentCharacter string.
Comment associated with the task. This comment will be visible in the task properties. This comment can be multilingual.
ScheduledTask.IdleWaitTimeoutInteger in minutes.
Timeout during which the system will wait for an idle time before performing the task.
If ScheduledTask.IdleTimeout is not set to 0, this variable is used to specify the amount of time required before the system cancels the task execution.
This variable is set to 60 minutes by default.
ScheduledTask.IdleTimeoutInteger in minutes.
Amount of system idle time required before performing the task. The task will be performed only if the system is inactive.
Example: An antivirus scan is performed every day at 1:00 PM if the system is inactive since 30 minutes.
This variable is set to 0 (immediate timeout) by default.
ScheduledTask.LastRunDateDateTime.
Date of last task execution.
This variable is read-only and is updated with SchedulerTaskProperties.
ScheduledTask.MaxRunTimeDuration.
Maximum task duration. Amount of time required before the system ends the task.
If this variable is set to 0, the task will be run as long as necessary.
This variable is set to 72 hours by default.
Note: This variable can correspond to:
  • an integer corresponding to the number of hundredths of a second,
  • a Duration variable,
  • direct indication of duration (e.g. 1 h).
ScheduledTask.SystemOnBoolean.
  • True if the computer must be woken up to perform this task (the system must not be in sleep mode),
  • False otherwise.
This variable is set to False by default.
ScheduledTask.RunIfLoggedOnBoolean.
  • True if the task must be performed only when an interactive session (with user identification) is started on the computer of user identified by ScheduledTask.User,
  • False otherwise.
This feature allows you not to specify the user password (however, the username must be specified).
The default value for this variable is False the task will run even if the session is closed.
Note: This variable only works with Windows XP (does not work with 2000).
ScheduledTask.CommandLineCharacter string.
Parameters to pass in command line to the application that will be run.
ScheduledTask.PasswordCharacter string.
User password. This user was specified in ScheduledTask.User. Used to perform a scheduled task according to a user account.
If this password is modified, this modification will also apply to all the tasks linked to this user.
ScheduledTask.TriggerCountInteger.
Number of task triggers (events that will start the task).
This variable is read-only and is updated with SchedulerTaskProperties.
ScheduledTask.DontRunIfOnBatteriesBoolean.
True if the task must be stopped when the computer switches to battery power.
This variable is set to True by default.
ScheduledTask.NextRunTimeDateTime.
Date of next scheduled task execution.
This variable is read-only and is updated with SchedulerTaskProperties.
ScheduledTask.WorkingDirectoryCharacter string.
Working directory of the application to run (empty string if the working directory corresponds to the scheduler directory (MSTASK.EXE)).
Caution: If this directory is not filled in, it corresponds to the PlannedTask.Application directory..
ScheduledTask.DeleteWhenDoneBoolean.
True if the task must be deleted automatically when there is no more possible conditions for running it (the end date of each occurrence has been reached for example).
This variable is set to False by default.
ScheduledTask.UserCharacter string.
Name of user whose account is used to perform the task.
Note: if you are using a domain, you need to specify the domain.
Example

Example for adding a task

SchedulerReset()
// Create the scheduled task
ScheduledTask.Application = "MyExecutable.exe"
ScheduledTask.CommandLine = QryAllAboutBackup.Name
ScheduledTask.SystemOn = True
ScheduledTask.Comment = "WINDEV program"

// Create the triggers for the scheduled task
// nBackupType is a radio button proposing a backup 
// single, weekly or monthly backup...

TriggerScheduledTask.Type = nBackupType

// Execution date of the single backup
IF nBackupType = schedDaily THEN
	IF EDT_SingleDate <> "" THEN
		IF EDT_SingleTime <> "" THEN
			TriggerScheduledTask.Date = EDT_SingleDate 
			TriggerScheduledTask.Time = EDT_SingleTime
		ELSE
			Info("Enter a valid backup time.")
			RETURN
		END
	ELSE
		Info("Enter a valid backup date.")
		RETURN
	END
END
// Monthly backup
IF nBackupType = schedMonthly THEN
	IF EDT_SingleTime <> "" THEN
		TriggerScheduledTask.Day = RADIO_DayOfMonth
		TriggerScheduledTask.Time = EDT_SingleTime
	ELSE
		Info("Enter a valid backup time.")
		RETURN
	END
END
// Weekly backup
IF nBackupType = schedWeekly THEN
	IF EDT_SingleTime <> "" THEN
		TriggerScheduledTask.DayOfWeek = RADIO_DayOfWeek
		TriggerScheduledTask.Time = EDT_SingleTime
	ELSE
		Info("Enter a valid backup time.")
		RETURN
	END
END
IF NOT SchedulerAddTask("MyTask") THEN 
	Error(ErrorInfo())
ELSE
	Info("The application was added to the task manager of Windows")
END
Versión mínima requerida
  • Versión 10
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 27/03/2025

Señalar un error o enviar una sugerencia | Ayuda local