I may have stated the obvious but only because you seem to have overlooked it. The hint between the lines is that you need to get the SID of the user in order to write to HKU\SID...

 Originally Posted By: Robdutoit
A free chocolate will be awarded to anyone who can solve my HKCU problem \:\)

Then you owe Glenn some chocolate cuz he solved it for you. I'm sure he has the bits to get the SID.

 Originally Posted By: Glenn Barnas

When updating HKCU entries that are secured (as above), the detection returns the user ID so the correct HKU key can be updated by the task.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.