ntdevlabs / tiny11builder

Scripts to build a trimmed-down Windows 11 image.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A few errors during image cleanup

eugenesan opened this issue · comments

I've noticed a few errors during image cleanup:

Disabling Teams:
DEBUG:  168+  >>>> & 'reg' 'add' 'HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Communications' '/v' 'ConfigureChatAutoInstall' '/t' 'REG_DWORD' '/d' '0'
'/f'
ERROR: Access is denied.
DEBUG:  196+  >>>> & 'reg' 'delete' 'HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager\SuggestedApps' '/f'
ERROR: The system was unable to find the specified registry key or value.
DEBUG:  210+  >>>> reg unload HKLM\zDRIVERS
ERROR: The parameter is incorrect.
DEBUG:  257+  >>>> reg unload HKLM\zSCHEMA
ERROR: The parameter is incorrect.

The image was Win11_23H2_English_x64.iso, Context:6

I've noticed a few errors during image cleanup:

Disabling Teams:
DEBUG:  168+  >>>> & 'reg' 'add' 'HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Communications' '/v' 'ConfigureChatAutoInstall' '/t' 'REG_DWORD' '/d' '0'
'/f'
ERROR: Access is denied.
DEBUG:  196+  >>>> & 'reg' 'delete' 'HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager\SuggestedApps' '/f'
ERROR: The system was unable to find the specified registry key or value.
DEBUG:  210+  >>>> reg unload HKLM\zDRIVERS
ERROR: The parameter is incorrect.
DEBUG:  257+  >>>> reg unload HKLM\zSCHEMA
ERROR: The parameter is incorrect.

The image was Win11_23H2_English_x64.iso, Context:6

Try this:

# Disable Teams
try {
    & 'reg' 'add' 'HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Communications' '/v' 'ConfigureChatAutoInstall' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null
} catch {
    Write-Host "Error disabling Teams: $_"
}

# Delete registry key if it exists
if (Test-Path "HKLM:\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager\SuggestedApps") {
    try {
        & 'reg' 'delete' 'HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager\SuggestedApps' '/f' | Out-Null
    } catch {
        Write-Host "Error deleting registry key: $_"
    }
}

# Unload registry hives
$registryHives = @('HKLM\zCOMPONENTS', 'HKLM\zDRIVERS', 'HKLM\zDEFAULT', 'HKLM\zNTUSER', 'HKLM\zSCHEMA', 'HKLM\zSOFTWARE', 'HKLM\zSYSTEM')

foreach ($hive in $registryHives) {
    try {
        & 'reg' 'unload' $hive | Out-Null
    } catch {
        Write-Host "Error unloading registry hive $hive: $_"
    }
}

# Remaining code for image cleanup...