I see you try to write in many keys that are dedicated to policies.
if you test the script with a local admin account, it can work but when executed during login script, this script can't write keys for non admin users because all these keys are read-only.

these values should be set by gpo
_________________________
Christophe