From 16905ac90db983be86052f40034f03a9d5d8a94a Mon Sep 17 00:00:00 2001 From: titus Date: Sat, 7 Mar 2026 22:29:46 -0600 Subject: [PATCH] wait for mounting to assign disk letter --- functions/private/Invoke-WinUtilISO.ps1 | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/functions/private/Invoke-WinUtilISO.ps1 b/functions/private/Invoke-WinUtilISO.ps1 index dccbf073..959c431f 100644 --- a/functions/private/Invoke-WinUtilISO.ps1 +++ b/functions/private/Invoke-WinUtilISO.ps1 @@ -49,8 +49,25 @@ function Invoke-WinUtilISOMountAndVerify { Set-WinUtilProgressBar -Label "Mounting ISO..." -Percent 10 try { - $diskImage = Mount-DiskImage -ImagePath $isoPath -PassThru -ErrorAction Stop - $driveLetter = ($diskImage | Get-Volume).DriveLetter + ":" + Mount-DiskImage -ImagePath $isoPath -ErrorAction Stop | Out-Null + + # Mount-DiskImage returns before Windows assigns a drive letter; retry until available. + $volume = $null + 1..10 | ForEach-Object { + $v = Get-DiskImage -ImagePath $isoPath | Get-Volume + if ($v.DriveLetter) { $volume = $v; return } + Start-Sleep -Milliseconds 500 + } + + if (-not $volume.DriveLetter) { + Dismount-DiskImage -ImagePath $isoPath | Out-Null + Write-Win11ISOLog "ERROR: Could not determine the mounted drive letter." + [System.Windows.MessageBox]::Show("The ISO was mounted but Windows did not assign a drive letter.`n`nPlease try again.", "Mount Failed", "OK", "Error") + Set-WinUtilProgressBar -Label "" -Percent 0 + return + } + + $driveLetter = $volume.DriveLetter + ":" Write-Win11ISOLog "Mounted at drive $driveLetter" Set-WinUtilProgressBar -Label "Verifying ISO contents..." -Percent 30