fix(windows): create missing registry keys in enable#43
Open
jabagawee wants to merge 1 commit into
Open
Conversation
On a fresh Windows install the Run key and the lazily created StartupApproved\Run key may not exist yet. enable() obtained each key through Registry.openPath, which throws when the key path is absent, and createValue (RegSetValueEx) only writes to an already-open handle without creating the key, so enable() threw on machines where these keys were missing. This switches enable() to Registry.currentUser.createKey, which creates the key and any missing parent keys along the path before writing, and opens an existing key unchanged. The registry paths are now constants shared with the read path. The read path and the value written for existing users are unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
enable()writes the autostart entries to theRunkey and the lazily createdStartupApproved\Runkey, obtaining each viaRegistry.openPath.openPaththrows when the key is absent, andcreateValue(RegSetValueEx) only writes to an already-open handle without creating the key, so on a fresh install where these keys don't exist yetenable()throws.This switches
enable()toRegistry.currentUser.createKey(...), which creates the key and any missing parents along the path before writing, and opens an existing key unchanged. The read path is untouched and existing users get the same written value as before; no new dependency. Counterpart to theisEnabled()fix in #42.