@@ -117,12 +117,33 @@ Write-Output "=== Welcome to the tiny11 image creator! Release: 09-07-25"
117117
118118$hostArchitecture = $Env: PROCESSOR_ARCHITECTURE
119119New-Item - ItemType Directory - Force - Path " $ScratchDisk \tiny11\sources" | Out-Null
120+
121+ $mountedImagePath = $null
122+
120123do {
121124 if (-not $ISO ) {
122- $DriveLetter = Read-Host " Please enter the drive letter for the Windows 11 image"
125+ $isoInput = Read-Host " Please enter the drive letter for the Windows 11 image, or a path to a Windows 11 ISO"
126+ $isoInput = $isoInput -replace ' "' , ' '
127+
128+ if ($isoInput -match ' ^[c-zC-Z]$' ) {
129+ $DriveLetter = $isoInput
130+ } elseif ((Test-Path $isoInput - PathType Leaf) -and ($isoInput -match ' \.iso$' )) {
131+ try {
132+ $DriveLetter = (Mount-DiskImage - ImagePath $isoInput - Access ReadOnly | Get-Volume | Select-Object - ExpandProperty DriveLetter)
133+ $mountedImagePath = $isoInput
134+ Write-Output " Selected ${isoInput} (mounted with drive letter ${DriveLetter} :)."
135+ } catch {
136+ Write-Output " Failed to mount ISO file. Please verify the image path and try again."
137+ $DriveLetter = $null
138+ }
139+ } else {
140+ Write-Output " Invalid input. Enter a drive letter (C-Z) or a valid .iso file path."
141+ $DriveLetter = $null
142+ }
123143 } else {
124144 $DriveLetter = $ISO
125145 }
146+
126147 if ($DriveLetter -match ' ^[c-zC-Z]$' ) {
127148 $DriveLetter = $DriveLetter + " :"
128149 Write-Output " Drive letter set to $DriveLetter "
@@ -149,6 +170,11 @@ if ((Test-Path "$DriveLetter\sources\boot.wim") -eq $false -or (Test-Path "$Driv
149170Write-Output " === Copying Windows image..."
150171
151172Copy-Item - Path " $DriveLetter \*" - Destination " $ScratchDisk \tiny11" - Recurse - Force | Out-Null
173+
174+ if ($mountedImagePath ) {
175+ Dismount-DiskImage - ImagePath $mountedImagePath - ErrorAction SilentlyContinue | Out-Null
176+ }
177+
152178Set-ItemProperty - Path " $ScratchDisk \tiny11\sources\install.esd" - Name IsReadOnly - Value $false - ErrorAction ' Continue' > $null 2>&1
153179Remove-Item " $ScratchDisk \tiny11\sources\install.esd" - ErrorAction ' Continue' > $null 2>&1
154180Write-Output " Copy complete!"
0 commit comments