This is what we use for unattended tasks

Get ComRegisterTaskDefinition of oFolder tSchedule.sTaskName vCom OLETASK_CREATE_OR_UPDATE tSchedule.sUserId tSchedule.sPassword OLETASK_LOGON_PASSWORD Nothing to vCom
There are certainly plenty of quirks with the whole process like not being allowed to edit an existing task setup directly in the scheduler is one case where you would get a null handle back

This long thread might have a clue to your issue but it's probably something simple in the task details you have setup

Things like if you are using Repetition the duration must be longer than then interval

I assume you have checked if the task already exists and if not called ComNewTask first ?

What sort of other things are you setting in the other collections before registering the task ?