Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve unattended answer file creation for MicroWin and add automatic conversion of ESD files #1595

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b659acb
Update applications.json
ChrisTitusTech Jan 26, 2024
aed9270
Compile Winutil
ChrisTitusTech Jan 26, 2024
c34c804
Update files
CodingWonders Jan 27, 2024
739bb49
Update screen-install.png (#1464)
Samq64 Jan 30, 2024
6ebf40d
Compile Winutil
ChrisTitusTech Jan 30, 2024
369f8a6
Merge branch 'test-2024-01-25' into CW-MicroWin
ChrisTitusTech Jan 30, 2024
440f892
applications.jsonAdded Foxit Reader app and updated Foxit Editor to s…
LoopTJ Feb 1, 2024
367485c
Compile Winutil
ChrisTitusTech Feb 1, 2024
5248954
Fix Broken Link and add syncthingtray (#1508)
RocGod Feb 1, 2024
9a58c9e
Compile Winutil
ChrisTitusTech Feb 1, 2024
090aecc
Remove Nano-Removed bugged Nano package for now
jesjess243 Feb 1, 2024
bac37a1
Compile Winutil
ChrisTitusTech Feb 1, 2024
8069364
tweaks and fetures tabs clean up automation from inputXML.xaml
ogfrm Feb 1, 2024
1d35d06
Compile Winutil
ChrisTitusTech Feb 1, 2024
26e117c
Choosing Alternate Scartch Path and Busy Messages
LeeDowA Feb 1, 2024
32e98c0
Compile Winutil
ChrisTitusTech Feb 1, 2024
6d4db7d
Merge branch 'test-2024-01-30' into CW-MicroWin
CodingWonders Feb 2, 2024
744fee6
Improve detection for Professional editions
CodingWonders Feb 2, 2024
42d13ad
Merge branch 'test-2024-02-07-refactor-noapps' into CW-MicroWin
CodingWonders Feb 9, 2024
2fbe40a
Update files
CodingWonders Feb 9, 2024
a37e435
Merge branch 'test-2024-02-07-refactor-noapps' into CW-MicroWin
ChrisTitusTech Feb 22, 2024
832f08c
Automatic conversion of ESD files
CodingWonders Mar 2, 2024
e21d4fa
Merge branch 'test-2024-02-07-refactor-noapps' into CW-MicroWin
ChrisTitusTech Mar 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 29 additions & 14 deletions functions/private/Invoke-MicroWin-Helper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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
}

Expand Down
9 changes: 7 additions & 2 deletions functions/public/Invoke-WPFGetIso.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 21 additions & 1 deletion functions/public/Invoke-WPFMicrowin.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
75 changes: 57 additions & 18 deletions winutil.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
Author : Chris Titus @christitustech
Runspace Author: @DeveloperDurp
GitHub : https://github.com/ChrisTitusTech
Version : 24.03.21
#>
param (
[switch]$Debug,
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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."
Expand Down