Summary
Remove-RegistryValue emits a NativeCommandError when the target registry key does not exist in the mounted image's default user hive. On the Windows 11 25H2 (June 2026) consumer ISO, the Subscriptions subkey under ContentDeliveryManager is absent, so reg delete fails with "The system was unable to find the specified registry key or value."
Environment
- ISO:
en-us_windows_11_consumer_editions_version_25h2_updated_june_2026_x64_dvd_2045a41c.iso
- Script:
tiny11maker.ps1 (release 09-07-25, current main)
- OS: Windows 11 (build host)
Error output
Set registry value: HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager\SystemPaneSuggestionsEnabled
Set registry value: HKLM\zSOFTWARE\Policies\Microsoft\PushToInstall\DisablePushToInstall
Set registry value: HKLM\zSOFTWARE\Policies\Microsoft\MRT\DontOfferThroughWUAU
Removed registry value: HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager\Subscriptions
reg.exe : ERROR: The system was unable to find the specified registry key or value.
At C:\tmp\tiny11\tiny11maker.ps1:63 char:3
+ & 'reg' 'delete' $path '/f' | Out-Null
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (ERROR: The syst...y key or value.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Removed registry value: HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager\SuggestedApps
Set registry value: HKLM\zSOFTWARE\Policies\Microsoft\Windows\CloudContent\DisableConsumerAccountStateContent
Root cause
The Remove-RegistryValue function (lines ~58-67) wraps reg delete in a try/catch and pipes to Out-Null:
function Remove-RegistryValue {
param ( [string]$path )
try {
& 'reg' 'delete' $path '/f' | Out-Null
Write-Output "Removed registry value: $path"
} catch {
Write-Output "Error removing registry value: $_"
}
}
Two problems:
Out-Null does not suppress native-command stderr in PowerShell 5.1. When reg.exe writes "ERROR: ..." to stderr, PowerShell surfaces it as a NativeCommandError record regardless of the | Out-Null pipe, and the try/catch does not reliably catch native-command stderr streams (the error record is written to the error stream before the catch block engages, depending on $ErrorActionPreference).
- The
Subscriptions key is genuinely absent in the 25H2 June 2026 image's Users\Default\ntuser.dat. This is expected — Microsoft has been progressively trimming the ContentDeliveryManager subtree across builds. The script should treat "key not found" as a non-fatal condition rather than surfacing it as an error.
Note the output also shows Removed registry value: ...Subscriptions before the error — the success Write-Output fires because reg delete's exit code path and stderr handling race the catch block.
Suggested fix
Check for the key's existence before deleting, and/or redirect stderr explicitly:
function Remove-RegistryValue {
param ( [string]$path )
if (-not (reg query $path 2>$null)) {
Write-Output "Skipped (not present): $path"
return
}
& 'reg' 'delete' $path '/f' 2>$null | Out-Null
if ($LASTEXITCODE -eq 0) {
Write-Output "Removed registry value: $path"
} else {
Write-Output "Skipped (exit $LASTEXITCODE): $path"
}
}
This makes absence non-fatal and removes the noisy NativeCommandError stack trace from the build log. The same hardening would apply to the other Remove-RegistryValue calls (e.g. the Edge uninstall keys, UScheduler_Oobe\OutlookUpdate, DevHomeUpdate) which may also be absent on future builds.
Impact
Non-fatal — the build completes and the resulting image is usable. The issue is cosmetic/log noise plus a misleading error message suggesting something failed when the key simply never existed. Worth fixing so users running the June 2026 25H2 ISO don't file duplicate reports.
Workaround
None needed — the error is benign. Users can ignore it.
Summary
Remove-RegistryValueemits aNativeCommandErrorwhen the target registry key does not exist in the mounted image's default user hive. On the Windows 11 25H2 (June 2026) consumer ISO, theSubscriptionssubkey underContentDeliveryManageris absent, soreg deletefails with "The system was unable to find the specified registry key or value."Environment
en-us_windows_11_consumer_editions_version_25h2_updated_june_2026_x64_dvd_2045a41c.isotiny11maker.ps1(release09-07-25, currentmain)Error output
Root cause
The
Remove-RegistryValuefunction (lines ~58-67) wrapsreg deletein atry/catchand pipes toOut-Null:Two problems:
Out-Nulldoes not suppress native-command stderr in PowerShell 5.1. Whenreg.exewrites "ERROR: ..." to stderr, PowerShell surfaces it as aNativeCommandErrorrecord regardless of the| Out-Nullpipe, and the try/catch does not reliably catch native-command stderr streams (the error record is written to the error stream before the catch block engages, depending on$ErrorActionPreference).Subscriptionskey is genuinely absent in the 25H2 June 2026 image'sUsers\Default\ntuser.dat. This is expected — Microsoft has been progressively trimming theContentDeliveryManagersubtree across builds. The script should treat "key not found" as a non-fatal condition rather than surfacing it as an error.Note the output also shows
Removed registry value: ...Subscriptionsbefore the error — the successWrite-Outputfires becausereg delete's exit code path and stderr handling race the catch block.Suggested fix
Check for the key's existence before deleting, and/or redirect stderr explicitly:
This makes absence non-fatal and removes the noisy
NativeCommandErrorstack trace from the build log. The same hardening would apply to the otherRemove-RegistryValuecalls (e.g. the Edge uninstall keys,UScheduler_Oobe\OutlookUpdate,DevHomeUpdate) which may also be absent on future builds.Impact
Non-fatal — the build completes and the resulting image is usable. The issue is cosmetic/log noise plus a misleading error message suggesting something failed when the key simply never existed. Worth fixing so users running the June 2026 25H2 ISO don't file duplicate reports.
Workaround
None needed — the error is benign. Users can ignore it.