Skip to content

fix(windows): create missing registry keys in enable#43

Open
jabagawee wants to merge 1 commit into
leanflutter:mainfrom
jabagawee:fix/windows-enable-missing-key
Open

fix(windows): create missing registry keys in enable#43
jabagawee wants to merge 1 commit into
leanflutter:mainfrom
jabagawee:fix/windows-enable-missing-key

Conversation

@jabagawee

Copy link
Copy Markdown

enable() writes the autostart entries to the Run key and the lazily created StartupApproved\Run key, obtaining each via Registry.openPath. openPath throws when the key is absent, and createValue (RegSetValueEx) only writes to an already-open handle without creating the key, so on a fresh install where these keys don't exist yet enable() throws.

This switches enable() to Registry.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 the isEnabled() fix in #42.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant