I would question if you really need to write to the registry at every log in. How about reading from the registry to see if the value exists? If not, then write.