From f7c072341d1a475b9463c9690721a07ecc6b1bb8 Mon Sep 17 00:00:00 2001 From: Omar <90123670+mewclouds@users.noreply.github.com> Date: Tue, 4 Aug 2026 17:01:12 -0400 Subject: [PATCH] Fix USB creation when install.wim is read-only (#4910) * fix: allow USB WIM splitting * test: guard USB WIM splitting fix --- functions/private/Invoke-WinUtilISOUSB.ps1 | 1 + pester/win11creator.Tests.ps1 | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/functions/private/Invoke-WinUtilISOUSB.ps1 b/functions/private/Invoke-WinUtilISOUSB.ps1 index 3d042eb5..f080450e 100644 --- a/functions/private/Invoke-WinUtilISOUSB.ps1 +++ b/functions/private/Invoke-WinUtilISOUSB.ps1 @@ -241,6 +241,7 @@ function Invoke-WinUtilISOWriteUSB { $wimSizeMB = [math]::Round((Get-Item $installWim).Length / 1MB) if ($wimSizeMB -gt 3800) { Log "install.wim is $wimSizeMB MB - splitting for FAT32 compatibility... This will take several minutes." + Set-ItemProperty -LiteralPath $installWim -Name IsReadOnly -Value $false $splitDest = Join-Path $usbDrive "sources\install.swm" New-Item -ItemType Directory -Path (Split-Path $splitDest) -Force Split-WindowsImage -ImagePath $installWim -SplitImagePath $splitDest -FileSize 3800 -CheckIntegrity diff --git a/pester/win11creator.Tests.ps1 b/pester/win11creator.Tests.ps1 index bd18bc9b..b689b0a8 100644 --- a/pester/win11creator.Tests.ps1 +++ b/pester/win11creator.Tests.ps1 @@ -191,6 +191,18 @@ Describe "Win11 Creator setup media" { $confirmationIndex | Should -BeGreaterThan $guardIndex } + It "clears install.wim read-only attribute before FAT32 splitting" { + $splitGuardIndex = $script:writeUsbFunction.IndexOf('$wimSizeMB -gt 3800') + $readOnlyResetIndex = $script:writeUsbFunction.IndexOf( + 'Set-ItemProperty -LiteralPath $installWim -Name IsReadOnly -Value $false' + ) + $splitCommandIndex = $script:writeUsbFunction.IndexOf('Split-WindowsImage') + + $splitGuardIndex | Should -BeGreaterThan -1 + $readOnlyResetIndex | Should -BeGreaterThan $splitGuardIndex + $splitCommandIndex | Should -BeGreaterThan $readOnlyResetIndex + } + It "maps Windows edition names to setup edition IDs" { . ([scriptblock]::Create($script:editionIdFunction))