quote:
The problem is that when execute the same batch file a second time,
I get the following error:

code:
[TRACE] Created trigger 0
[TRACE] Setting account information
[TRACE] Setting job's properties
[TRACE] Adding job 'Test.job'
[FAIL ] ITaskScheduler::AddWorkItemn hr=0x80070005

That's right, as a safety measure it wil not continue.
Comment the return if you don't want this feature.

; delete a potentially existing task
$shellcmd=$jtexe+' /SM \\'+$computer+' /SD +$taskname
shell '%COMSPEC% /e:1024 /c '+$shellcmd
if @ERROR
  $scheduletask=@ERROR
;  return
endif