mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-12-27 16:31:30 -06:00
Automatic conversion of ESD files
Automatically convert the install.esd file from installation media into a WIM file that can be mounted, then delete the ESD file
This commit is contained in:
parent
a37e435949
commit
832f08c18b
@ -160,13 +160,18 @@ function Invoke-WPFGetIso {
|
||||
$wimFile = "$mountDir\sources\install.wim"
|
||||
Write-Host "Getting image information $wimFile"
|
||||
|
||||
if (-not (Test-Path -Path $wimFile -PathType Leaf))
|
||||
if ((-not (Test-Path -Path $wimFile -PathType Leaf)) -and (-not (Test-Path -Path $wimFile.Replace(".wim", ".esd").Trim() -PathType Leaf)))
|
||||
{
|
||||
$msg = "Install.wim file doesn't exist in the image, this could happen if you use unofficial Windows images, or a Media creation tool, which creates a final image that can not be modified. Please don't use shady images from the internet, use only official images. Here are instructions how to download ISO images if the Microsoft website is not showing the link to download and ISO. https://www.techrepublic.com/article/how-to-download-a-windows-10-iso-file-without-using-the-media-creation-tool/"
|
||||
$msg = "Neither install.wim nor install.esd exist in the image, this could happen if you use unofficial Windows images. Please don't use shady images from the internet, use only official images. Here are instructions how to download ISO images if the Microsoft website is not showing the link to download and ISO. https://www.techrepublic.com/article/how-to-download-a-windows-10-iso-file-without-using-the-media-creation-tool/"
|
||||
Write-Host $msg
|
||||
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Error)
|
||||
throw
|
||||
}
|
||||
elseif ((-not (Test-Path -Path $wimFile -PathType Leaf)) -and (Test-Path -Path $wimFile.Replace(".wim", ".esd").Trim() -PathType Leaf))
|
||||
{
|
||||
Write-Host "Install.esd found on the image. It needs to be converted to a WIM file in order to begin processing"
|
||||
$wimFile = $wimFile.Replace(".wim", ".esd").Trim()
|
||||
}
|
||||
$sync.MicrowinWindowsFlavors.Items.Clear()
|
||||
Get-WindowsImage -ImagePath $wimFile | ForEach-Object {
|
||||
$imageIdx = $_.ImageIndex
|
||||
|
@ -57,6 +57,26 @@ public class PowerManagement {
|
||||
$mountDir = $sync.MicrowinMountDir.Text
|
||||
$scratchDir = $sync.MicrowinScratchDir.Text
|
||||
|
||||
# Detect if the Windows image is an ESD file and convert it to WIM
|
||||
if (-not (Test-Path -Path $mountDir\sources\install.wim -PathType Leaf) -and (Test-Path -Path $mountDir\sources\install.esd -PathType Leaf))
|
||||
{
|
||||
Write-Host "Exporting Windows image to a WIM file, keeping the index we want to work on. This can take several minutes, depending on the performance of your computer..."
|
||||
Export-WindowsImage -SourceImagePath $mountDir\sources\install.esd -SourceIndex $index -DestinationImagePath $mountDir\sources\install.wim -CompressionType "Max"
|
||||
if ($?)
|
||||
{
|
||||
Remove-Item -Path $mountDir\sources\install.esd -Force
|
||||
# Since we've already exported the image index we wanted, switch to the first one
|
||||
$index = 1
|
||||
}
|
||||
else
|
||||
{
|
||||
$msg = "The export process has failed and MicroWin processing cannot continue"
|
||||
Write-Host "Failed to export the image"
|
||||
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Error)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
$imgVersion = (Get-WindowsImage -ImagePath $mountDir\sources\install.wim -Index $index).Version
|
||||
|
||||
# Detect image version to avoid performing MicroWin processing on Windows 8 and earlier
|
||||
|
32
winutil.ps1
32
winutil.ps1
@ -10,6 +10,7 @@
|
||||
Author : Chris Titus @christitustech
|
||||
Runspace Author: @DeveloperDurp
|
||||
GitHub : https://github.com/ChrisTitusTech
|
||||
Version : 24.03.02
|
||||
#>
|
||||
param (
|
||||
[switch]$Debug,
|
||||
@ -46,7 +47,7 @@ Add-Type -AssemblyName System.Windows.Forms
|
||||
# Variable to sync between runspaces
|
||||
$sync = [Hashtable]::Synchronized(@{})
|
||||
$sync.PSScriptRoot = $PSScriptRoot
|
||||
$sync.version = "24.02.22"
|
||||
$sync.version = "24.03.02"
|
||||
$sync.configs = @{}
|
||||
$sync.ProcessRunning = $false
|
||||
|
||||
@ -3207,13 +3208,18 @@ function Invoke-WPFGetIso {
|
||||
$wimFile = "$mountDir\sources\install.wim"
|
||||
Write-Host "Getting image information $wimFile"
|
||||
|
||||
if (-not (Test-Path -Path $wimFile -PathType Leaf))
|
||||
if ((-not (Test-Path -Path $wimFile -PathType Leaf)) -and (-not (Test-Path -Path $wimFile.Replace(".wim", ".esd").Trim() -PathType Leaf)))
|
||||
{
|
||||
$msg = "Install.wim file doesn't exist in the image, this could happen if you use unofficial Windows images, or a Media creation tool, which creates a final image that can not be modified. Please don't use shady images from the internet, use only official images. Here are instructions how to download ISO images if the Microsoft website is not showing the link to download and ISO. https://www.techrepublic.com/article/how-to-download-a-windows-10-iso-file-without-using-the-media-creation-tool/"
|
||||
$msg = "Neither install.wim nor install.esd exist in the image, this could happen if you use unofficial Windows images. Please don't use shady images from the internet, use only official images. Here are instructions how to download ISO images if the Microsoft website is not showing the link to download and ISO. https://www.techrepublic.com/article/how-to-download-a-windows-10-iso-file-without-using-the-media-creation-tool/"
|
||||
Write-Host $msg
|
||||
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Error)
|
||||
throw
|
||||
}
|
||||
elseif ((-not (Test-Path -Path $wimFile -PathType Leaf)) -and (Test-Path -Path $wimFile.Replace(".wim", ".esd").Trim() -PathType Leaf))
|
||||
{
|
||||
Write-Host "Install.esd found on the image. It needs to be converted to a WIM file in order to begin processing"
|
||||
$wimFile = $wimFile.Replace(".wim", ".esd").Trim()
|
||||
}
|
||||
$sync.MicrowinWindowsFlavors.Items.Clear()
|
||||
Get-WindowsImage -ImagePath $wimFile | ForEach-Object {
|
||||
$imageIdx = $_.ImageIndex
|
||||
@ -3441,6 +3447,26 @@ public class PowerManagement {
|
||||
$mountDir = $sync.MicrowinMountDir.Text
|
||||
$scratchDir = $sync.MicrowinScratchDir.Text
|
||||
|
||||
# Detect if the Windows image is an ESD file and convert it to WIM
|
||||
if (-not (Test-Path -Path $mountDir\sources\install.wim -PathType Leaf) -and (Test-Path -Path $mountDir\sources\install.esd -PathType Leaf))
|
||||
{
|
||||
Write-Host "Exporting Windows image to a WIM file, keeping the index we want to work on. This can take several minutes, depending on the performance of your computer..."
|
||||
Export-WindowsImage -SourceImagePath $mountDir\sources\install.esd -SourceIndex $index -DestinationImagePath $mountDir\sources\install.wim -CompressionType "Max"
|
||||
if ($?)
|
||||
{
|
||||
Remove-Item -Path $mountDir\sources\install.esd -Force
|
||||
# Since we've already exported the image index we wanted, switch to the first one
|
||||
$index = 1
|
||||
}
|
||||
else
|
||||
{
|
||||
$msg = "The export process has failed and MicroWin processing cannot continue"
|
||||
Write-Host "Failed to export the image"
|
||||
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Error)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
$imgVersion = (Get-WindowsImage -ImagePath $mountDir\sources\install.wim -Index $index).Version
|
||||
|
||||
# Detect image version to avoid performing MicroWin processing on Windows 8 and earlier
|
||||
|
Loading…
Reference in New Issue
Block a user