I have changed my code to:
#include "TaskScheduler.au3"
Local $oService = _TS_Open()
_TS_ErrorNotify(2) ; to MsgBox
if _TS_TaskExists($oService,"\Test\starttime") Then
_TS_TaskDelete($oService,"\Test\starttime")
EndIf
Local $startTime = _DateAdd("n",1,_NowCalc())
$startTime = StringReplace($startTime,"/","-")
$startTime = StringReplace($startTime," ","T")
Local $endTime = _DateAdd("n",2,_NowCalc())
$endTime = StringReplace($endTime,"/","-")
$endTime = StringReplace($endTime," ","T")
Local $oTaskDefinition = _TS_Wrapper_TaskCreate($oService, "", "")
if $oTaskDefinition=0 then MsgBox(1,11,"bad")
_TS_Wrapper_PrincipalSet($oTaskDefinition,$TASK_LOGON_INTERACTIVE_TOKEN)
if @error<>0 then msgbox(1,13,"bad")
_TS_Wrapper_TriggerDateTime($oTaskDefinition,$TASK_TRIGGER_TIME,0, 0, $startTime,$endTime)
if @error<>0 then msgbox(1,15,"bad")
_TS_Wrapper_ActionCreate($oTaskDefinition,"Notepad")
if @error<>0 then msgbox(1,17,"bad")
if _TS_FolderExists($oService,"\Test")=0 Then
_TS_FolderCreate($oService,"\Test")
EndIf
_TS_Wrapper_TaskRegister($oService, "\Test","starttime",$oTaskDefinition, Default, Default,$TASK_LOGON_INTERACTIVE_TOKEN)
if @error<>0 then msgbox(1,22,"bad")
Local $ar = ["Settings|DeleteExpiredTaskAfter|PT20S"]
_TS_TaskPropertiesSet($oTaskDefinition,$ar)
if @error<>0 Then MsgBox(1,"DeleteExpiredTaskAfter",@error)
MsgBox(1,30,"$startTime " & $startTime & " $endTime " & $endTime)
Local $ar = _TS_TaskValidate($oService,"\Test\starttime")
_TS_Close($oService)
I see this:
I see similar for lines 1198, 2017 and 2022. None of the msgBoxes show.
NotePad opens as expected. I then close it.
I do now have PT20S