Win11Debloat icon indicating copy to clipboard operation
Win11Debloat copied to clipboard

Some options do not work correctly in Sysprep mode

Open Raphire opened this issue 1 year ago • 4 comments

Describe the bug Some options don't apply to any accounts if the script is run in Sysprep mode within the Windows Audit Mode environment.

  • Hide or change the search icon/box on the taskbar.
  • Hide the gallery section from the File Explorer sidepanel.
  • Restore the old Windows 10 style context menu.

To Reproduce Steps to reproduce the behavior:

  1. Start fresh installation of Windows 11
  2. Enter audit mode during OOBE (Ctrl + Shift + F3)
  3. Execute the script in Sysprep mode & select the options mentioned above
  4. Reboot
  5. Go through OOBE

Expected behavior The above mentioned options should apply to the account after going through OOBE

Raphire avatar Aug 02 '24 13:08 Raphire

After testing this I have been able to determine the script does apply the registry changes correctly to the default user profile. It seems however that these changes are not copied over to new users. I have been looking for alternative ways to apply these changes, but no luck so far.

Raphire avatar Aug 20 '24 18:08 Raphire

@Raphire, this might not fix your problem because you did say the change took effect properly, but you might try doing garbage collection first before closing the default registry hive. This is how I've done it in the past to ensure the hive takes effect properly. I had to do this during an Autopilot process or even though the registry got the change on the default hive the user that logged in wouldn't get the changed value.

        # $ITErrorCodes is a hashtable with keys with the friendly names of status codes and values for their errorcode number.  These lines can be omitted in your use case, this is just how my code worked.
        $unloaded = $false
        $attempts = 0
        $exitCode = $ITErrorCodes.Success
        while ((-not $unloaded) -and ($attempts -le 10)) {
            $attempts += 1
            Write-Host "Unloading the default user registry hive.  Attempt $attempts."
            [gc]::Collect()
            Start-Sleep -Seconds 5
            & reg.exe unload "$ITDefaultUserHiveLoad"
            $unloaded = $?
        }
        if (-not $unloaded) {
            Write-Warning "Unable to dismount default user registry hive at $ITDefaultUserHiveLoad.  Manual dismount required"
            Write-Warning "Setting exit code to $($ITErrorCodes.SuccessRebootRequired) SuccessRebootRequired"
            $exitCode = $ITErrorCodes.SuccessRebootRequired
        }

sean-sauve avatar Aug 27 '24 20:08 sean-sauve

Here's a better explanation. Apparently you're also supposed to close open handles before doing the garbage collection.

https://dansonnenburg.wordpress.com/2022/03/22/setting-value-in-the-default-user-registry-hive/

sean-sauve avatar Aug 27 '24 21:08 sean-sauve

@sean-sauve Thanks for the additional info and an example of your implementation. I am planning on reworking the way the script applies registry edits to also tackle #72.

Raphire avatar Aug 28 '24 17:08 Raphire

I think it's the same I read on the forum at the end of https://ccmexec.com/2021/10/modifying-windows-11-start-button-location-and-taskbar-icons-during-osd-autopilot/ and I reported on thread #104

LuCarhub avatar Sep 02 '24 14:09 LuCarhub

With 6b7c4db the following options now work in Sysprep mode:

  • Hide or change the search icon/box on the taskbar.
  • Hide the gallery section from the File Explorer sidepanel.
  • Restore the old Windows 10 style context menu.

Please note that these changes are applied to the user account after the OOBE, this means that they will have to sign-out and back in before the changes are visible.

Raphire avatar Sep 04 '24 15:09 Raphire