Write the new environment vars to the registry. Fixes 987.