When installing script is launched, it needs administrative privilege to register task. But the task is registered with user account, which is only fine if the user has permanent privilege access.
The task should be created with local system account, which ensures that the script is launched on next reboot, even if the user has no privilege by default.
AFAIU, this can be done by setting the right SID in the task XML file.
<Principal id="Author">
<UserId>SID of Local System</UserId>
<RunLevel>HighestAvailable</RunLevel>
</Principal>
A workaround is to edit the task manually as administrator after it is created.
Thanks for the script anyway: it rocks!