mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-12-28 08:51:31 -06:00
Improve unattended answer file creation for MicroWin and add automatic conversion of ESD files (#1595)
* Update applications.json Fake app add made by linux fanboy * Compile Winutil * Update files - Add detections for whether the image to be processed by MicroWin is Windows 10 or later - Add procedure to clear the indexes ComboBox (WinForms term) every time an ISO is specified * Update screen-install.png (#1464) * Compile Winutil * applications.jsonAdded Foxit Reader app and updated Foxit Editor to show the difference. * applications.json Added Foxit Reader app and updated Foxit Editor to show the difference. * Compile Winutil * Fix Broken Link and add syncthingtray (#1508) * Compile Winutil * Remove Nano-Removed bugged Nano package for now * Remove Nano -Removed bugged Nano package for now * Compile Winutil * tweaks and fetures tabs clean up automation from inputXML.xaml * tweaks and fetures tabs clean up automation from inputXML.xaml * fixed some commas in tweaks.json file * recompile * Update tweaks.json * Compile Winutil * Choosing Alternate Scartch Path and Busy Messages * Choosing Alternate Scartch Path and Busy Messages * Change Selected index to be pro * Compile Winutil * Improve detection for Professional editions * Update files Updated the Test-CompatibleImage function to compare against a desired version, which is useful for determining if the Specialize pass needs to be added to the unattended answer file * 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 --------- Co-authored-by: Chris Titus <dfm.titus@gmail.com> Co-authored-by: ChrisTitusTech <ChrisTitusTech@users.noreply.github.com> Co-authored-by: Samq64 <81489795+Samq64@users.noreply.github.com> Co-authored-by: Chris Titus <contact@christitus.com> Co-authored-by: LoopTJ <34551682+LoopTJ@users.noreply.github.com> Co-authored-by: Roc Wang <rocwang911@gmail.com> Co-authored-by: Jes Herring <123990927+jesjess243@users.noreply.github.com> Co-authored-by: ogfrm <96927197+ogfrm@users.noreply.github.com> Co-authored-by: LeeDowA <157072913+LeeDowA@users.noreply.github.com>
This commit is contained in:
parent
b8397ff49f
commit
821cd10fa8
@ -18,28 +18,23 @@ function Test-CompatibleImage() {
|
||||
<#
|
||||
|
||||
.SYNOPSIS
|
||||
Checks the version of a Windows image and determines whether or not it is compatible depending on the Major property
|
||||
Checks the version of a Windows image and determines whether or not it is compatible with a specific feature depending on a desired version
|
||||
|
||||
.PARAMETER imgVersion
|
||||
The version of the Windows image
|
||||
.PARAMETER Name
|
||||
imgVersion - The version of the Windows image
|
||||
desiredVersion - The version to compare the image version with
|
||||
|
||||
#>
|
||||
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true)] [string] $imgVersion
|
||||
[Parameter(Mandatory = $true, Position=0)] [string] $imgVersion,
|
||||
[Parameter(Mandatory = $true, Position=1)] [Version] $desiredVersion
|
||||
)
|
||||
|
||||
try {
|
||||
$version = [Version]$imgVersion
|
||||
if ($version.Major -ge 10)
|
||||
{
|
||||
return $True
|
||||
}
|
||||
else
|
||||
{
|
||||
return $False
|
||||
}
|
||||
return $version -ge $desiredVersion
|
||||
} catch {
|
||||
return $False
|
||||
}
|
||||
@ -247,7 +242,7 @@ function Remove-FileOrDirectory([string] $pathToDelete, [string] $mask = "", [sw
|
||||
|
||||
foreach($itemToDelete in $itemsToDelete)
|
||||
{
|
||||
$status = "Deleteing $($itemToDelete)"
|
||||
$status = "Deleting $($itemToDelete)"
|
||||
Write-Progress -Activity "Removing Items" -Status $status -PercentComplete ($counter++/$itemsToDelete.Count*100)
|
||||
|
||||
if (Test-Path -Path "$($itemToDelete)" -PathType Container)
|
||||
@ -321,7 +316,7 @@ function New-Unattend {
|
||||
<unattend xmlns="urn:schemas-microsoft-com:unattend"
|
||||
xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<#REPLACEME#>
|
||||
<settings pass="auditUser">
|
||||
<component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<RunSynchronous>
|
||||
@ -362,6 +357,26 @@ function New-Unattend {
|
||||
</settings>
|
||||
</unattend>
|
||||
'@
|
||||
$specPass = @'
|
||||
<settings pass="specialize">
|
||||
<component name="Microsoft-Windows-SQMApi" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<CEIPEnabled>0</CEIPEnabled>
|
||||
</component>
|
||||
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<ConfigureChatAutoInstall>false</ConfigureChatAutoInstall>
|
||||
</component>
|
||||
</settings>
|
||||
'@
|
||||
if ((Test-CompatibleImage $imgVersion $([System.Version]::new(10,0,22000,1))) -eq $false)
|
||||
{
|
||||
# Replace the placeholder text with an empty string to make it valid for Windows 10 Setup
|
||||
$unattend = $unattend.Replace("<#REPLACEME#>", "").Trim()
|
||||
}
|
||||
else
|
||||
{
|
||||
# Replace the placeholder text with the Specialize pass
|
||||
$unattend = $unattend.Replace("<#REPLACEME#>", $specPass).Trim()
|
||||
}
|
||||
$unattend | Out-File -FilePath "$env:temp\unattend.xml" -Force
|
||||
}
|
||||
|
||||
|
@ -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,10 +57,30 @@ 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
|
||||
if ((Test-CompatibleImage $imgVersion) -eq $false)
|
||||
if ((Test-CompatibleImage $imgVersion $([System.Version]::new(10,0,10240,0))) -eq $false)
|
||||
{
|
||||
$msg = "This image is not compatible with MicroWin processing. Make sure it isn't a Windows 8 or earlier image."
|
||||
$dlg_msg = $msg + "`n`nIf you want more information, the version of the image selected is $($imgVersion)`n`nIf an image has been incorrectly marked as incompatible, report an issue to the developers."
|
||||
|
75
winutil.ps1
75
winutil.ps1
@ -10,7 +10,6 @@
|
||||
Author : Chris Titus @christitustech
|
||||
Runspace Author: @DeveloperDurp
|
||||
GitHub : https://github.com/ChrisTitusTech
|
||||
Version : 24.03.21
|
||||
#>
|
||||
param (
|
||||
[switch]$Debug,
|
||||
@ -751,28 +750,23 @@ function Test-CompatibleImage() {
|
||||
<#
|
||||
|
||||
.SYNOPSIS
|
||||
Checks the version of a Windows image and determines whether or not it is compatible depending on the Major property
|
||||
Checks the version of a Windows image and determines whether or not it is compatible with a specific feature depending on a desired version
|
||||
|
||||
.PARAMETER imgVersion
|
||||
The version of the Windows image
|
||||
.PARAMETER Name
|
||||
imgVersion - The version of the Windows image
|
||||
desiredVersion - The version to compare the image version with
|
||||
|
||||
#>
|
||||
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true)] [string] $imgVersion
|
||||
[Parameter(Mandatory = $true, Position=0)] [string] $imgVersion,
|
||||
[Parameter(Mandatory = $true, Position=1)] [Version] $desiredVersion
|
||||
)
|
||||
|
||||
try {
|
||||
$version = [Version]$imgVersion
|
||||
if ($version.Major -ge 10)
|
||||
{
|
||||
return $True
|
||||
}
|
||||
else
|
||||
{
|
||||
return $False
|
||||
}
|
||||
return $version -ge $desiredVersion
|
||||
} catch {
|
||||
return $False
|
||||
}
|
||||
@ -980,7 +974,7 @@ function Remove-FileOrDirectory([string] $pathToDelete, [string] $mask = "", [sw
|
||||
|
||||
foreach($itemToDelete in $itemsToDelete)
|
||||
{
|
||||
$status = "Deleteing $($itemToDelete)"
|
||||
$status = "Deleting $($itemToDelete)"
|
||||
Write-Progress -Activity "Removing Items" -Status $status -PercentComplete ($counter++/$itemsToDelete.Count*100)
|
||||
|
||||
if (Test-Path -Path "$($itemToDelete)" -PathType Container)
|
||||
@ -1054,7 +1048,7 @@ function New-Unattend {
|
||||
<unattend xmlns="urn:schemas-microsoft-com:unattend"
|
||||
xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<#REPLACEME#>
|
||||
<settings pass="auditUser">
|
||||
<component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<RunSynchronous>
|
||||
@ -1095,6 +1089,26 @@ function New-Unattend {
|
||||
</settings>
|
||||
</unattend>
|
||||
'@
|
||||
$specPass = @'
|
||||
<settings pass="specialize">
|
||||
<component name="Microsoft-Windows-SQMApi" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<CEIPEnabled>0</CEIPEnabled>
|
||||
</component>
|
||||
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<ConfigureChatAutoInstall>false</ConfigureChatAutoInstall>
|
||||
</component>
|
||||
</settings>
|
||||
'@
|
||||
if ((Test-CompatibleImage $imgVersion $([System.Version]::new(10,0,22000,1))) -eq $false)
|
||||
{
|
||||
# Replace the placeholder text with an empty string to make it valid for Windows 10 Setup
|
||||
$unattend = $unattend.Replace("<#REPLACEME#>", "").Trim()
|
||||
}
|
||||
else
|
||||
{
|
||||
# Replace the placeholder text with the Specialize pass
|
||||
$unattend = $unattend.Replace("<#REPLACEME#>", $specPass).Trim()
|
||||
}
|
||||
$unattend | Out-File -FilePath "$env:temp\unattend.xml" -Force
|
||||
}
|
||||
|
||||
@ -3193,13 +3207,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
|
||||
@ -3427,10 +3446,30 @@ 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
|
||||
if ((Test-CompatibleImage $imgVersion) -eq $false)
|
||||
if ((Test-CompatibleImage $imgVersion $([System.Version]::new(10,0,10240,0))) -eq $false)
|
||||
{
|
||||
$msg = "This image is not compatible with MicroWin processing. Make sure it isn't a Windows 8 or earlier image."
|
||||
$dlg_msg = $msg + "`n`nIf you want more information, the version of the image selected is $($imgVersion)`n`nIf an image has been incorrectly marked as incompatible, report an issue to the developers."
|
||||
|
Loading…
Reference in New Issue
Block a user