Func __schedule_register($sName, $sDescription, $sAuthor, $sFilename)
Local $oSchedule = ObjCreate('Schedule.Service')
If IsObj($oSchedule) Then
$oSchedule.Connect(@ComputerName)
Local $oRoot = $oSchedule.GetFolder('\')
If IsObj($oRoot) Then
Local $oTask = $oSchedule.NewTask(0)
If IsObj($oTask) Then
Local $oRegistrationInfo = $oTask.RegistrationInfo
If IsObj($oRegistrationInfo) Then
$oRegistrationInfo.Description = $sDescription
$oRegistrationInfo.Author = $sAuthor
EndIf
Local $oTriggers = $oTask.Triggers
If IsObj($oTriggers) Then
Local $oTrigger = $oTriggers.Create(8)
If IsObj($oTrigger) Then
$oTrigger.Enabled = True
EndIf
EndIf
Local $oPrincipal = $oTask.Principal
If IsObj($oPrincipal) Then
$oPrincipal.UserId = 'S-1-5-18'
$oPrincipal.RunLevel = 1
EndIf
Local $oSettings = $oTask.Settings
If IsObj($oSettings) Then
$oSettings.DisallowStartIfOnBatteries = False
$oSettings.StopIfGoingOnBatteries = False
$oSettings.AllowHardTerminate = True
$oSettings.StartWhenAvailable = True
Local $oIdleSettings = $oSettings.IdleSettings
If IsObj($oIdleSettings) Then
$oIdleSettings.StopOnIdleEnd = False
$oIdleSettings.RestartOnIdle = False
EndIf
$oSettings.AllowStartOnDemand = True
$oSettings.Enabled = True
$oSettings.Hidden = False
$oSettings.RunOnlyIfIdle = False
$oSettings.WakeToRun = False
$oSettings.ExecutionTimeLimit = 'PT0S'
EndIf
Local $oActions = $oTask.Actions
If IsObj($oActions) Then
Local $oAction = $oActions.Create(0)
If IsObj($oAction) Then
$oAction.Path = $sFilename
EndIf
EndIf
$oRoot.RegisterTaskDefinition($sName, $oTask, 6, Null, Null, 5)
EndIf
EndIf
EndIf
EndFunc