What keys are you writing to? Can you attach your reg file? Are they HKLM?
I am trying to add setting in here for VNC Viewer
I have run into issues with this because of UAC. I'd check there first.
Another alternative, depending on how many keys you are looking to add/modify, is to use the reg.exe command and add your line(s) in one at a time.
I've had success there as well.
Unfortunately I do not know how to get around the UAC. We have that enabled on all of our PCs by default. I actually tried using the reg.exe commands as well but had the same results. I found a way around it by creating a simple msi that adds the reg settings.
I would still like to figure out what the cause is.