From 4a413b344eee7ea8c312879be6e4e3f8d759fb94 Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Sat, 20 Jul 2024 11:56:35 +0200 Subject: [PATCH] automatic drive mount in coremaker --- tiny11Coremaker.ps1 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tiny11Coremaker.ps1 b/tiny11Coremaker.ps1 index 4031647..930e98d 100644 --- a/tiny11Coremaker.ps1 +++ b/tiny11Coremaker.ps1 @@ -43,17 +43,17 @@ Clear-Host $mainOSDrive = $env:SystemDrive $hostArchitecture = $Env:PROCESSOR_ARCHITECTURE New-Item -ItemType Directory -Force -Path "$mainOSDrive\tiny11\sources" >null -$DriveLetter = Read-Host "Please enter the drive letter for the Windows 11 image" -$DriveLetter = $DriveLetter + ":" +$ImagePath = Read-Host "Paste the image path (without quotes) here" +$DriveLetter = Mount-DiskImage -ImagePath "$ImagePath" | Get-Volume | Select-Object -ExpandProperty DriveLetter -if ((Test-Path "$DriveLetter\sources\boot.wim") -eq $false -or (Test-Path "$DriveLetter\sources\install.wim") -eq $false) { - if ((Test-Path "$DriveLetter\sources\install.esd") -eq $true) { +if ((Test-Path "${DriveLetter}:\sources\boot.wim") -eq $false -or (Test-Path "${DriveLetter}:\sources\install.wim") -eq $false) { + if ((Test-Path "${DriveLetter}:\sources\install.esd") -eq $true) { Write-Host "Found install.esd, converting to install.wim..." - & 'dism' '/English' "/Get-WimInfo" "/wimfile:$DriveLetter\sources\install.esd" + & 'dism' '/English' "/Get-WimInfo" "/wimfile:${DriveLetter}:\sources\install.esd" $index = Read-Host "Please enter the image index" Write-Host ' ' Write-Host 'Converting install.esd to install.wim. This may take a while...' - & 'DISM' /Export-Image /SourceImageFile:"$DriveLetter\sources\install.esd" /SourceIndex:$index /DestinationImageFile:"$mainOSDrive\tiny11\sources\install.wim" /Compress:max /CheckIntegrity + & 'DISM' /Export-Image /SourceImageFile:"${DriveLetter}:\sources\install.esd" /SourceIndex:$index /DestinationImageFile:"$mainOSDrive\tiny11\sources\install.wim" /Compress:max /CheckIntegrity } else { Write-Host "Can't find Windows OS Installation files in the specified Drive Letter.." Write-Host "Please enter the correct DVD Drive Letter.." @@ -62,7 +62,7 @@ if ((Test-Path "$DriveLetter\sources\boot.wim") -eq $false -or (Test-Path "$Driv } Write-Host "Copying Windows image..." -Copy-Item -Path "$DriveLetter\*" -Destination "$mainOSDrive\tiny11" -Recurse -Force > null +Copy-Item -Path "${DriveLetter}:\*" -Destination "$mainOSDrive\tiny11" -Recurse -Force > null Set-ItemProperty -Path "$mainOSDrive\tiny11\sources\install.esd" -Name IsReadOnly -Value $false > $null 2>&1 Remove-Item "$mainOSDrive\tiny11\sources\install.esd" > $null 2>&1 Write-Host "Copy complete!"