Skip to content

Guard newUsers.ps1 against re-running on accidental Windows profile reset - #1

Closed
Stensel8 with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-issue-1607-in-forked-repo
Closed

Guard newUsers.ps1 against re-running on accidental Windows profile reset#1
Stensel8 with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-issue-1607-in-forked-repo

Conversation

Copilot AI commented Mar 10, 2026

Copy link
Copy Markdown

Questions

Describe your pull request

On Windows 11 24H2/25H2, a sleep/wake cycle can trigger Windows to recreate an existing user's profile from the Default user template. Since Atlas plants a RunOnce entry in the Default user hive, newUsers.ps1 fires again on the recreated profile — forcing a logoff and wiping the user's settings as if they were a brand-new account.

…ly reset by Windows

When Windows 11 24H2/25H2 accidentally resets an existing user's profile (e.g.,
after sleep/wake), the new profile inherits the Default user hive's RunOnce entry
which Atlas places for new-user setup. This causes newUsers.ps1 to run again,
unexpectedly logging the user out and wiping their current profile settings.

Fix: after a successful first-time run, record the user's SID in
HKLM\SOFTWARE\AtlasOS\UserSetup. On subsequent runs (e.g., after a profile reset),
the script checks for this persistent marker and exits silently instead of forcing
a logoff. Genuine new user accounts (with a different SID) are unaffected.

Addresses: Atlas-OS#1607

Co-authored-by: Stensel8 <102481635+Stensel8@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue 1607 in forked AtlasOS repo Guard newUsers.ps1 against re-running on accidental Windows profile reset Mar 10, 2026
@Stensel8
Stensel8 marked this pull request as ready for review March 10, 2026 10:29
Copilot AI review requested due to automatic review settings March 10, 2026 10:29
@Stensel8

Copy link
Copy Markdown
Owner

Testing and reviewing this change first. This will not be merged in, unless it is deemed stable.

This comment was marked as outdated.

@Stensel8

Copy link
Copy Markdown
Owner

@copilot apply changes based on the comments in this thread

- Move the idempotency guard before self-elevation so that already-configured
  accounts silently exit without triggering a UAC prompt
- Remove the Write-Host from the silent exit path (no output during logon)
- Use New-ItemProperty -PropertyType DWord instead of Set-ItemProperty -Type DWORD
  which does not support the -Type parameter
- Add comment clarifying the marker is written at the very end (after all setup
  steps succeed) to prevent permanently skipping a partially-configured account

Co-authored-by: Stensel8 <102481635+Stensel8@users.noreply.github.com>

Copilot AI commented Mar 10, 2026

Copy link
Copy Markdown
Author

@copilot apply changes based on the comments in this thread

All 4 review comments applied in commit 6d65d70:

@Stensel8 Stensel8 added bug Something isn't working question Further information is requested labels Mar 10, 2026

This comment was marked as off-topic.

@Stensel8 Stensel8 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok

@Stensel8

Stensel8 commented Apr 27, 2026

Copy link
Copy Markdown
Owner

Superseded by Atlas-OS#1644

@Stensel8 Stensel8 closed this Apr 27, 2026
@Stensel8
Stensel8 deleted the copilot/fix-issue-1607-in-forked-repo branch April 27, 2026 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working question Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants