mirror of
https://github.com/ChrisTitusTech/winutil
synced 2026-04-05 22:28:31 +00:00
Compare commits
4 Commits
26.03.04
...
751b7ef79c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
751b7ef79c | ||
|
|
689cf656c0 | ||
|
|
114f671237 | ||
|
|
81aee4ead9 |
14
Compile.ps1
14
Compile.ps1
@@ -103,6 +103,20 @@ $xaml
|
||||
'@
|
||||
"@)
|
||||
|
||||
Update-Progress "Adding: autounattend.xml" 95
|
||||
$autounattendRaw = Get-Content "$workingdir\tools\autounattend.xml" -Raw
|
||||
# Strip XML comments (<!-- ... -->, including multi-line)
|
||||
$autounattendRaw = [regex]::Replace($autounattendRaw, '<!--.*?-->', '', [System.Text.RegularExpressions.RegexOptions]::Singleline)
|
||||
# Drop blank lines and trim trailing whitespace per line
|
||||
$autounattendXml = ($autounattendRaw -split "`r?`n" |
|
||||
Where-Object { $_.Trim() -ne '' } |
|
||||
ForEach-Object { $_.TrimEnd() }) -join "`r`n"
|
||||
$script_content.Add(@"
|
||||
`$WinUtilAutounattendXml = @'
|
||||
$autounattendXml
|
||||
'@
|
||||
"@)
|
||||
|
||||
$script_content.Add($(Get-Content "scripts\main.ps1"))
|
||||
|
||||
Update-Progress "Removing temporary files" 99
|
||||
|
||||
@@ -65,10 +65,12 @@
|
||||
"ButtonTweaksBackgroundColor": "#F7F7F7",
|
||||
"ButtonConfigBackgroundColor": "#F7F7F7",
|
||||
"ButtonUpdatesBackgroundColor": "#F7F7F7",
|
||||
"ButtonWin11ISOBackgroundColor": "#F7F7F7",
|
||||
"ButtonInstallForegroundColor": "#232629",
|
||||
"ButtonTweaksForegroundColor": "#232629",
|
||||
"ButtonConfigForegroundColor": "#232629",
|
||||
"ButtonUpdatesForegroundColor": "#232629",
|
||||
"ButtonWin11ISOForegroundColor": "#232629",
|
||||
"ButtonBackgroundColor": "#F5F5F5",
|
||||
"ButtonBackgroundPressedColor": "#1A1A1A",
|
||||
"ButtonBackgroundMouseoverColor": "#C2C2C2",
|
||||
@@ -105,10 +107,12 @@
|
||||
"ButtonTweaksBackgroundColor": "#333333",
|
||||
"ButtonConfigBackgroundColor": "#444444",
|
||||
"ButtonUpdatesBackgroundColor": "#555555",
|
||||
"ButtonWin11ISOBackgroundColor": "#666666",
|
||||
"ButtonInstallForegroundColor": "#F7F7F7",
|
||||
"ButtonTweaksForegroundColor": "#F7F7F7",
|
||||
"ButtonConfigForegroundColor": "#F7F7F7",
|
||||
"ButtonUpdatesForegroundColor": "#F7F7F7",
|
||||
"ButtonWin11ISOForegroundColor": "#F7F7F7",
|
||||
"ButtonBackgroundColor": "#1E3747",
|
||||
"ButtonBackgroundPressedColor": "#F7F7F7",
|
||||
"ButtonBackgroundMouseoverColor": "#3B4252",
|
||||
|
||||
572
functions/private/Invoke-WinUtilISO.ps1
Normal file
572
functions/private/Invoke-WinUtilISO.ps1
Normal file
@@ -0,0 +1,572 @@
|
||||
function Write-Win11ISOLog {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Appends a timestamped message to the Win11ISO status log TextBox.
|
||||
.PARAMETER Message
|
||||
The message to append.
|
||||
#>
|
||||
param([string]$Message)
|
||||
$timestamp = (Get-Date).ToString("HH:mm:ss")
|
||||
$sync["WPFWin11ISOStatusLog"].Dispatcher.Invoke([action]{
|
||||
$current = $sync["WPFWin11ISOStatusLog"].Text
|
||||
if ($current -eq "Ready. Please select a Windows 11 ISO to begin.") {
|
||||
$sync["WPFWin11ISOStatusLog"].Text = "[$timestamp] $Message"
|
||||
} else {
|
||||
$sync["WPFWin11ISOStatusLog"].Text += "`n[$timestamp] $Message"
|
||||
}
|
||||
$sync["WPFWin11ISOStatusLog"].ScrollToEnd()
|
||||
})
|
||||
}
|
||||
|
||||
function Invoke-WinUtilISOBrowse {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Opens an OpenFileDialog so the user can choose a Windows 11 ISO file.
|
||||
Populates WPFWin11ISOPath and reveals the Mount & Verify section (Step 2).
|
||||
#>
|
||||
Add-Type -AssemblyName System.Windows.Forms
|
||||
|
||||
$dlg = [System.Windows.Forms.OpenFileDialog]::new()
|
||||
$dlg.Title = "Select Windows 11 ISO"
|
||||
$dlg.Filter = "ISO files (*.iso)|*.iso|All files (*.*)|*.*"
|
||||
$dlg.InitialDirectory = [System.Environment]::GetFolderPath("Desktop")
|
||||
|
||||
if ($dlg.ShowDialog() -ne [System.Windows.Forms.DialogResult]::OK) { return }
|
||||
|
||||
$isoPath = $dlg.FileName
|
||||
|
||||
# ── Basic size sanity-check (a Win11 ISO is typically > 4 GB) ──
|
||||
$fileSizeGB = [math]::Round((Get-Item $isoPath).Length / 1GB, 2)
|
||||
|
||||
$sync["WPFWin11ISOPath"].Text = $isoPath
|
||||
$sync["WPFWin11ISOFileInfo"].Text = "File size: $fileSizeGB GB"
|
||||
$sync["WPFWin11ISOFileInfo"].Visibility = "Visible"
|
||||
|
||||
# Reveal Step 2
|
||||
$sync["WPFWin11ISOMountSection"].Visibility = "Visible"
|
||||
|
||||
# Collapse all later steps whenever a new ISO is chosen
|
||||
$sync["WPFWin11ISOVerifyResultPanel"].Visibility = "Collapsed"
|
||||
$sync["WPFWin11ISOModifySection"].Visibility = "Collapsed"
|
||||
$sync["WPFWin11ISOOutputSection"].Visibility = "Collapsed"
|
||||
|
||||
Write-Win11ISOLog "ISO selected: $isoPath ($fileSizeGB GB)"
|
||||
}
|
||||
|
||||
function Invoke-WinUtilISOMountAndVerify {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Mounts the selected ISO, verifies it is a valid Windows 11 image,
|
||||
and populates the edition list. Reveals Step 3 on success.
|
||||
#>
|
||||
$isoPath = $sync["WPFWin11ISOPath"].Text
|
||||
|
||||
if ([string]::IsNullOrWhiteSpace($isoPath) -or $isoPath -eq "No ISO selected...") {
|
||||
[System.Windows.MessageBox]::Show(
|
||||
"Please select an ISO file first.",
|
||||
"No ISO Selected", "OK", "Warning")
|
||||
return
|
||||
}
|
||||
|
||||
Write-Win11ISOLog "Mounting ISO: $isoPath"
|
||||
Set-WinUtilProgressBar -Label "Mounting ISO..." -Percent 10
|
||||
|
||||
try {
|
||||
# Mount the ISO
|
||||
$diskImage = Mount-DiskImage -ImagePath $isoPath -PassThru -ErrorAction Stop
|
||||
$driveLetter = ($diskImage | Get-Volume).DriveLetter + ":"
|
||||
Write-Win11ISOLog "Mounted at drive $driveLetter"
|
||||
|
||||
Set-WinUtilProgressBar -Label "Verifying ISO contents..." -Percent 30
|
||||
|
||||
# ── Verify install.wim / install.esd presence ──
|
||||
$wimPath = Join-Path $driveLetter "sources\install.wim"
|
||||
$esdPath = Join-Path $driveLetter "sources\install.esd"
|
||||
|
||||
if (-not (Test-Path $wimPath) -and -not (Test-Path $esdPath)) {
|
||||
Dismount-DiskImage -ImagePath $isoPath | Out-Null
|
||||
Write-Win11ISOLog "ERROR: install.wim/install.esd not found — not a valid Windows ISO."
|
||||
[System.Windows.MessageBox]::Show(
|
||||
"This does not appear to be a valid Windows ISO.`n`ninstall.wim / install.esd was not found.",
|
||||
"Invalid ISO", "OK", "Error")
|
||||
Set-WinUtilProgressBar -Label "" -Percent 0
|
||||
return
|
||||
}
|
||||
|
||||
$activeWim = if (Test-Path $wimPath) { $wimPath } else { $esdPath }
|
||||
|
||||
# ── Read edition / architecture info ──
|
||||
Set-WinUtilProgressBar -Label "Reading image metadata..." -Percent 55
|
||||
|
||||
$editions = Get-WindowsImage -ImagePath $activeWim | Select-Object -ExpandProperty ImageName
|
||||
|
||||
# ── Verify at least one Win11 edition is present ──
|
||||
$isWin11 = $editions | Where-Object { $_ -match "Windows 11" }
|
||||
if (-not $isWin11) {
|
||||
Dismount-DiskImage -ImagePath $isoPath | Out-Null
|
||||
Write-Win11ISOLog "ERROR: No 'Windows 11' edition found in the image."
|
||||
[System.Windows.MessageBox]::Show(
|
||||
"No Windows 11 edition was found in this ISO.`n`nOnly official Windows 11 ISOs are supported.",
|
||||
"Not a Windows 11 ISO", "OK", "Error")
|
||||
Set-WinUtilProgressBar -Label "" -Percent 0
|
||||
return
|
||||
}
|
||||
|
||||
# ── Populate UI ──
|
||||
$sync["WPFWin11ISOMountDriveLetter"].Text = "Mounted at: $driveLetter | Image file: $(Split-Path $activeWim -Leaf)"
|
||||
$sync["WPFWin11ISOEditionList"].Text = ($editions -join "`n")
|
||||
$sync["WPFWin11ISOVerifyResultPanel"].Visibility = "Visible"
|
||||
|
||||
# Store for later steps
|
||||
$sync["Win11ISODriveLetter"] = $driveLetter
|
||||
$sync["Win11ISOWimPath"] = $activeWim
|
||||
$sync["Win11ISOImagePath"] = $isoPath
|
||||
|
||||
# Reveal Step 3
|
||||
$sync["WPFWin11ISOModifySection"].Visibility = "Visible"
|
||||
|
||||
Set-WinUtilProgressBar -Label "ISO verified ✔" -Percent 100
|
||||
Write-Win11ISOLog "ISO verified OK. Editions found: $($editions.Count)"
|
||||
}
|
||||
catch {
|
||||
Write-Win11ISOLog "ERROR during mount/verify: $_"
|
||||
[System.Windows.MessageBox]::Show(
|
||||
"An error occurred while mounting or verifying the ISO:`n`n$_",
|
||||
"Error", "OK", "Error")
|
||||
}
|
||||
finally {
|
||||
Start-Sleep -Milliseconds 800
|
||||
Set-WinUtilProgressBar -Label "" -Percent 0
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-WinUtilISOModify {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Extracts ISO contents to a temp working directory, modifies install.wim,
|
||||
then repackages the image. Reveals Step 4 (output options) on success.
|
||||
|
||||
.NOTES
|
||||
This function runs inside a PowerShell runspace so the UI stays responsive.
|
||||
Placeholder modification logic is provided; extend as needed.
|
||||
#>
|
||||
|
||||
$isoPath = $sync["Win11ISOImagePath"]
|
||||
$driveLetter= $sync["Win11ISODriveLetter"]
|
||||
$wimPath = $sync["Win11ISOWimPath"]
|
||||
|
||||
if (-not $isoPath) {
|
||||
[System.Windows.MessageBox]::Show(
|
||||
"No verified ISO found. Please complete Steps 1 and 2 first.",
|
||||
"Not Ready", "OK", "Warning")
|
||||
return
|
||||
}
|
||||
|
||||
# Disable the modify button to prevent double-click
|
||||
$sync["WPFWin11ISOModifyButton"].IsEnabled = $false
|
||||
|
||||
$workDir = Join-Path $env:TEMP "WinUtil_Win11ISO_$(Get-Date -Format 'yyyyMMdd_HHmmss')"
|
||||
|
||||
# ── Run modification in a background runspace ──
|
||||
$runspace = [Management.Automation.Runspaces.RunspaceFactory]::CreateRunspace()
|
||||
$runspace.ApartmentState = "STA"
|
||||
$runspace.ThreadOptions = "ReuseThread"
|
||||
$runspace.Open()
|
||||
$runspace.SessionStateProxy.SetVariable("sync", $sync)
|
||||
$runspace.SessionStateProxy.SetVariable("isoPath", $isoPath)
|
||||
$runspace.SessionStateProxy.SetVariable("driveLetter", $driveLetter)
|
||||
$runspace.SessionStateProxy.SetVariable("wimPath", $wimPath)
|
||||
$runspace.SessionStateProxy.SetVariable("workDir", $workDir)
|
||||
|
||||
# Serialize functions so they are available inside the runspace
|
||||
$isoScriptFuncDef = "function Invoke-WinUtilISOScript {`n" + `
|
||||
${function:Invoke-WinUtilISOScript}.ToString() + "`n}"
|
||||
$runspace.SessionStateProxy.SetVariable("isoScriptFuncDef", $isoScriptFuncDef)
|
||||
|
||||
$win11ISOLogFuncDef = "function Write-Win11ISOLog {`n" + `
|
||||
${function:Write-Win11ISOLog}.ToString() + "`n}"
|
||||
$runspace.SessionStateProxy.SetVariable("win11ISOLogFuncDef", $win11ISOLogFuncDef)
|
||||
|
||||
$refreshUSBFuncDef = "function Invoke-WinUtilISORefreshUSBDrives {`n" + `
|
||||
${function:Invoke-WinUtilISORefreshUSBDrives}.ToString() + "`n}"
|
||||
$runspace.SessionStateProxy.SetVariable("refreshUSBFuncDef", $refreshUSBFuncDef)
|
||||
|
||||
$script = [Management.Automation.PowerShell]::Create()
|
||||
$script.Runspace = $runspace
|
||||
$script.AddScript({
|
||||
|
||||
# Import helper functions into this runspace
|
||||
. ([scriptblock]::Create($isoScriptFuncDef))
|
||||
. ([scriptblock]::Create($win11ISOLogFuncDef))
|
||||
. ([scriptblock]::Create($refreshUSBFuncDef))
|
||||
|
||||
function Log($msg) {
|
||||
$ts = (Get-Date).ToString("HH:mm:ss")
|
||||
$sync["WPFWin11ISOStatusLog"].Dispatcher.Invoke([action]{
|
||||
$sync["WPFWin11ISOStatusLog"].Text += "`n[$ts] $msg"
|
||||
$sync["WPFWin11ISOStatusLog"].ScrollToEnd()
|
||||
})
|
||||
}
|
||||
|
||||
function SetProgress($label, $pct) {
|
||||
$sync["WPFWin11ISOStatusLog"].Dispatcher.Invoke([action]{
|
||||
$sync.progressBarTextBlock.Text = $label
|
||||
$sync.progressBarTextBlock.ToolTip = $label
|
||||
$sync.ProgressBar.Value = [Math]::Max($pct, 5)
|
||||
})
|
||||
}
|
||||
|
||||
try {
|
||||
# ── 1. Create working directory structure ──
|
||||
Log "Creating working directory: $workDir"
|
||||
$isoContents = Join-Path $workDir "iso_contents"
|
||||
$mountDir = Join-Path $workDir "wim_mount"
|
||||
New-Item -ItemType Directory -Path $isoContents, $mountDir -Force | Out-Null
|
||||
SetProgress "Copying ISO contents..." 10
|
||||
|
||||
# ── 2. Copy all ISO contents to the working directory ──
|
||||
Log "Copying ISO contents from $driveLetter to $isoContents..."
|
||||
$robocopyArgs = @($driveLetter, $isoContents, "/E", "/NFL", "/NDL", "/NJH", "/NJS")
|
||||
& robocopy @robocopyArgs | Out-Null
|
||||
Log "ISO contents copied."
|
||||
SetProgress "Mounting install.wim..." 25
|
||||
|
||||
# ── 3. Copy install.wim to working dir (it may be read-only on the DVD) ──
|
||||
$localWim = Join-Path $isoContents "sources\install.wim"
|
||||
if (-not (Test-Path $localWim)) {
|
||||
# ESD path
|
||||
$localWim = Join-Path $isoContents "sources\install.esd"
|
||||
}
|
||||
# Ensure the file is writable
|
||||
Set-ItemProperty -Path $localWim -Name IsReadOnly -Value $false
|
||||
|
||||
# ── 4. Mount the first index of install.wim ──
|
||||
Log "Mounting install.wim (Index 1) at $mountDir..."
|
||||
Mount-WindowsImage -ImagePath $localWim -Index 1 -Path $mountDir -ErrorAction Stop | Out-Null
|
||||
SetProgress "Modifying install.wim..." 45
|
||||
|
||||
# ── Apply all WinUtil modifications via Invoke-WinUtilISOScript ──
|
||||
Log "Applying WinUtil modifications to install.wim..."
|
||||
Invoke-WinUtilISOScript -ScratchDir $mountDir -Log { param($m) Log $m }
|
||||
|
||||
# ── 5. Save and dismount the WIM ──
|
||||
SetProgress "Saving modified install.wim..." 65
|
||||
Log "Dismounting and saving install.wim..."
|
||||
Dismount-WindowsImage -Path $mountDir -Save -ErrorAction Stop | Out-Null
|
||||
Log "install.wim saved."
|
||||
SetProgress "Dismounting source ISO..." 80
|
||||
|
||||
# ── 6. Dismount the original ISO ──
|
||||
Log "Dismounting original ISO..."
|
||||
Dismount-DiskImage -ImagePath $isoPath | Out-Null
|
||||
|
||||
# Store work directory for output steps
|
||||
$sync["Win11ISOWorkDir"] = $workDir
|
||||
$sync["Win11ISOContentsDir"] = $isoContents
|
||||
|
||||
SetProgress "Modification complete ✔" 100
|
||||
Log "install.wim modification complete. Select an output option in Step 4."
|
||||
|
||||
# ── Reveal Step 4 on the UI thread ──
|
||||
$sync["WPFWin11ISOOutputSection"].Dispatcher.Invoke([action]{
|
||||
$sync["WPFWin11ISOOutputSection"].Visibility = "Visible"
|
||||
Invoke-WinUtilISORefreshUSBDrives
|
||||
})
|
||||
}
|
||||
catch {
|
||||
Log "ERROR during modification: $_"
|
||||
$sync["WPFWin11ISOStatusLog"].Dispatcher.Invoke([action]{
|
||||
[System.Windows.MessageBox]::Show(
|
||||
"An error occurred during install.wim modification:`n`n$_",
|
||||
"Modification Error", "OK", "Error")
|
||||
})
|
||||
}
|
||||
finally {
|
||||
Start-Sleep -Milliseconds 800
|
||||
$sync["WPFWin11ISOStatusLog"].Dispatcher.Invoke([action]{
|
||||
$sync.progressBarTextBlock.Text = ""
|
||||
$sync.progressBarTextBlock.ToolTip = ""
|
||||
$sync.ProgressBar.Value = 0
|
||||
$sync["WPFWin11ISOModifyButton"].IsEnabled = $true
|
||||
})
|
||||
}
|
||||
}) | Out-Null
|
||||
|
||||
$script.BeginInvoke() | Out-Null
|
||||
}
|
||||
|
||||
function Invoke-WinUtilISOExport {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Saves the modified ISO contents as a new bootable ISO file.
|
||||
Uses oscdimg.exe (part of the Windows ADK) if present; falls back
|
||||
to a reminder message if not installed.
|
||||
#>
|
||||
$contentsDir = $sync["Win11ISOContentsDir"]
|
||||
|
||||
if (-not $contentsDir -or -not (Test-Path $contentsDir)) {
|
||||
[System.Windows.MessageBox]::Show(
|
||||
"No modified ISO content found. Please complete Steps 1–3 first.",
|
||||
"Not Ready", "OK", "Warning")
|
||||
return
|
||||
}
|
||||
|
||||
Add-Type -AssemblyName System.Windows.Forms
|
||||
|
||||
$dlg = [System.Windows.Forms.SaveFileDialog]::new()
|
||||
$dlg.Title = "Save Modified Windows 11 ISO"
|
||||
$dlg.Filter = "ISO files (*.iso)|*.iso"
|
||||
$dlg.FileName = "Win11_Modified_$(Get-Date -Format 'yyyyMMdd').iso"
|
||||
$dlg.InitialDirectory = [System.Environment]::GetFolderPath("Desktop")
|
||||
|
||||
if ($dlg.ShowDialog() -ne [System.Windows.Forms.DialogResult]::OK) { return }
|
||||
|
||||
$outputISO = $dlg.FileName
|
||||
Write-Win11ISOLog "Exporting to ISO: $outputISO"
|
||||
Set-WinUtilProgressBar -Label "Building ISO..." -Percent 10
|
||||
|
||||
# Locate oscdimg.exe (Windows ADK)
|
||||
$oscdimg = Get-ChildItem "C:\Program Files (x86)\Windows Kits" -Recurse -Filter "oscdimg.exe" -ErrorAction SilentlyContinue |
|
||||
Select-Object -First 1 -ExpandProperty FullName
|
||||
|
||||
if (-not $oscdimg) {
|
||||
Set-WinUtilProgressBar -Label "" -Percent 0
|
||||
Write-Win11ISOLog "oscdimg.exe not found. Install Windows ADK to enable ISO export."
|
||||
[System.Windows.MessageBox]::Show(
|
||||
"oscdimg.exe was not found.`n`nTo export an ISO you need the Windows Assessment and Deployment Kit (ADK).`n`nDownload it from: https://learn.microsoft.com/windows-hardware/get-started/adk-install",
|
||||
"Windows ADK Required", "OK", "Warning")
|
||||
return
|
||||
}
|
||||
|
||||
# Build boot parameters (BIOS + UEFI dual-boot)
|
||||
$bootData = "2#p0,e,b`"$contentsDir\boot\etfsboot.com`"#pEF,e,b`"$contentsDir\efi\microsoft\boot\efisys.bin`""
|
||||
$oscdimgArgs = @(
|
||||
"-m", # ignore source path max size
|
||||
"-o", # optimise storage
|
||||
"-u2", # UDF 2.01
|
||||
"-udfver102",
|
||||
"-bootdata:$bootData",
|
||||
"-l`"CTOS_MODIFIED`"",
|
||||
"`"$contentsDir`"",
|
||||
"`"$outputISO`""
|
||||
)
|
||||
|
||||
try {
|
||||
Write-Win11ISOLog "Running oscdimg..."
|
||||
$proc = Start-Process -FilePath $oscdimg -ArgumentList $oscdimgArgs -Wait -PassThru -NoNewWindow
|
||||
if ($proc.ExitCode -eq 0) {
|
||||
Set-WinUtilProgressBar -Label "ISO exported ✔" -Percent 100
|
||||
Write-Win11ISOLog "ISO exported successfully: $outputISO"
|
||||
[System.Windows.MessageBox]::Show(
|
||||
"ISO exported successfully!`n`n$outputISO",
|
||||
"Export Complete", "OK", "Info")
|
||||
} else {
|
||||
Write-Win11ISOLog "oscdimg exited with code $($proc.ExitCode)."
|
||||
[System.Windows.MessageBox]::Show(
|
||||
"oscdimg exited with code $($proc.ExitCode).`nCheck the status log for details.",
|
||||
"Export Error", "OK", "Error")
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Win11ISOLog "ERROR during ISO export: $_"
|
||||
[System.Windows.MessageBox]::Show("ISO export failed:`n`n$_","Error","OK","Error")
|
||||
}
|
||||
finally {
|
||||
Start-Sleep -Milliseconds 800
|
||||
Set-WinUtilProgressBar -Label "" -Percent 0
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-WinUtilISORefreshUSBDrives {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Populates the USB drive ComboBox with all currently attached removable drives.
|
||||
#>
|
||||
$combo = $sync["WPFWin11ISOUSBDriveComboBox"]
|
||||
$combo.Items.Clear()
|
||||
|
||||
$removable = Get-Disk | Where-Object { $_.BusType -eq "USB" } | Sort-Object Number
|
||||
|
||||
if ($removable.Count -eq 0) {
|
||||
$combo.Items.Add("No USB drives detected")
|
||||
$combo.SelectedIndex = 0
|
||||
Write-Win11ISOLog "No USB drives detected."
|
||||
return
|
||||
}
|
||||
|
||||
foreach ($disk in $removable) {
|
||||
$sizeGB = [math]::Round($disk.Size / 1GB, 1)
|
||||
$label = "Disk $($disk.Number): $($disk.FriendlyName) [$sizeGB GB] — $($disk.PartitionStyle)"
|
||||
$combo.Items.Add($label)
|
||||
}
|
||||
$combo.SelectedIndex = 0
|
||||
Write-Win11ISOLog "Found $($removable.Count) USB drive(s)."
|
||||
|
||||
# Store disk objects for later use
|
||||
$sync["Win11ISOUSBDisks"] = $removable
|
||||
}
|
||||
|
||||
function Invoke-WinUtilISOWriteUSB {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Erases the selected USB drive and writes the modified Windows 11 ISO
|
||||
content as a bootable installation drive (using DISM / robocopy approach).
|
||||
#>
|
||||
$contentsDir = $sync["Win11ISOContentsDir"]
|
||||
$usbDisks = $sync["Win11ISOUSBDisks"]
|
||||
|
||||
if (-not $contentsDir -or -not (Test-Path $contentsDir)) {
|
||||
[System.Windows.MessageBox]::Show(
|
||||
"No modified ISO content found. Please complete Steps 1–3 first.",
|
||||
"Not Ready", "OK", "Warning")
|
||||
return
|
||||
}
|
||||
|
||||
$selectedIndex = $sync["WPFWin11ISOUSBDriveComboBox"].SelectedIndex
|
||||
if ($selectedIndex -lt 0 -or -not $usbDisks -or $selectedIndex -ge $usbDisks.Count) {
|
||||
[System.Windows.MessageBox]::Show(
|
||||
"Please select a USB drive from the dropdown.",
|
||||
"No Drive Selected", "OK", "Warning")
|
||||
return
|
||||
}
|
||||
|
||||
$targetDisk = $usbDisks[$selectedIndex]
|
||||
$diskNum = $targetDisk.Number
|
||||
$sizeGB = [math]::Round($targetDisk.Size / 1GB, 1)
|
||||
|
||||
$confirm = [System.Windows.MessageBox]::Show(
|
||||
"ALL data on Disk $diskNum ($($targetDisk.FriendlyName), $sizeGB GB) will be PERMANENTLY ERASED.`n`nAre you sure you want to continue?",
|
||||
"Confirm USB Erase", "YesNo", "Warning")
|
||||
|
||||
if ($confirm -ne "Yes") {
|
||||
Write-Win11ISOLog "USB write cancelled by user."
|
||||
return
|
||||
}
|
||||
|
||||
$sync["WPFWin11ISOWriteUSBButton"].IsEnabled = $false
|
||||
Write-Win11ISOLog "Starting USB write to Disk $diskNum..."
|
||||
|
||||
$runspace = [Management.Automation.Runspaces.RunspaceFactory]::CreateRunspace()
|
||||
$runspace.ApartmentState = "STA"
|
||||
$runspace.ThreadOptions = "ReuseThread"
|
||||
$runspace.Open()
|
||||
$runspace.SessionStateProxy.SetVariable("sync", $sync)
|
||||
$runspace.SessionStateProxy.SetVariable("diskNum", $diskNum)
|
||||
$runspace.SessionStateProxy.SetVariable("contentsDir", $contentsDir)
|
||||
|
||||
$script = [Management.Automation.PowerShell]::Create()
|
||||
$script.Runspace = $runspace
|
||||
$script.AddScript({
|
||||
|
||||
function Log($msg) {
|
||||
$ts = (Get-Date).ToString("HH:mm:ss")
|
||||
$sync["WPFWin11ISOStatusLog"].Dispatcher.Invoke([action]{
|
||||
$sync["WPFWin11ISOStatusLog"].Text += "`n[$ts] $msg"
|
||||
$sync["WPFWin11ISOStatusLog"].ScrollToEnd()
|
||||
})
|
||||
}
|
||||
function SetProgress($label, $pct) {
|
||||
$sync["WPFWin11ISOStatusLog"].Dispatcher.Invoke([action]{
|
||||
$sync.progressBarTextBlock.Text = $label
|
||||
$sync.progressBarTextBlock.ToolTip = $label
|
||||
$sync.ProgressBar.Value = [Math]::Max($pct, 5)
|
||||
})
|
||||
}
|
||||
|
||||
try {
|
||||
SetProgress "Formatting USB drive..." 10
|
||||
|
||||
# ── Diskpart script: clean, GPT, create ESP + data partitions ──
|
||||
$dpScript = @"
|
||||
select disk $diskNum
|
||||
clean
|
||||
convert gpt
|
||||
create partition efi size=512
|
||||
format quick fs=fat32 label="SYSTEM"
|
||||
assign
|
||||
create partition primary
|
||||
format quick fs=fat32 label="WINPE"
|
||||
assign
|
||||
exit
|
||||
"@
|
||||
$dpFile = Join-Path $env:TEMP "winutil_diskpart_$(Get-Random).txt"
|
||||
$dpScript | Set-Content -Path $dpFile -Encoding ASCII
|
||||
Log "Running diskpart on Disk $diskNum..."
|
||||
diskpart /s $dpFile | Out-Null
|
||||
Remove-Item $dpFile -Force
|
||||
|
||||
SetProgress "Identifying USB partitions..." 30
|
||||
Start-Sleep -Seconds 3 # let Windows assign drive letters
|
||||
|
||||
# Find newly assigned drive letter for the data partition
|
||||
$usbVol = Get-Partition -DiskNumber $diskNum |
|
||||
Where-Object { $_.Type -eq "Basic" } |
|
||||
Get-Volume |
|
||||
Where-Object { $_.FileSystemLabel -eq "WINPE" } |
|
||||
Select-Object -First 1
|
||||
|
||||
if (-not $usbVol) {
|
||||
throw "Could not locate the formatted USB data partition. Drive letter may not have been assigned automatically."
|
||||
}
|
||||
|
||||
$usbDrive = "$($usbVol.DriveLetter):"
|
||||
Log "USB data partition: $usbDrive"
|
||||
SetProgress "Copying Windows 11 files to USB..." 45
|
||||
|
||||
# ── Copy files (split large install.wim if > 4 GB for FAT32) ──
|
||||
$installWim = Join-Path $contentsDir "sources\install.wim"
|
||||
if (Test-Path $installWim) {
|
||||
$wimSizeMB = [math]::Round((Get-Item $installWim).Length / 1MB)
|
||||
if ($wimSizeMB -gt 3800) {
|
||||
# FAT32 limit – split with DISM
|
||||
Log "install.wim is $wimSizeMB MB – splitting for FAT32 compatibility..."
|
||||
$splitDest = Join-Path $usbDrive "sources\install.swm"
|
||||
New-Item -ItemType Directory -Path (Split-Path $splitDest) -Force | Out-Null
|
||||
Split-WindowsImage -ImagePath $installWim `
|
||||
-SplitImagePath $splitDest `
|
||||
-FileSize 3800 -CheckIntegrity | Out-Null
|
||||
Log "install.wim split complete."
|
||||
|
||||
# Copy everything else (exclude install.wim)
|
||||
$robocopyArgs = @($contentsDir, $usbDrive, "/E", "/XF", "install.wim", "/NFL", "/NDL", "/NJH", "/NJS")
|
||||
& robocopy @robocopyArgs | Out-Null
|
||||
} else {
|
||||
& robocopy $contentsDir $usbDrive /E /NFL /NDL /NJH /NJS | Out-Null
|
||||
}
|
||||
} else {
|
||||
& robocopy $contentsDir $usbDrive /E /NFL /NDL /NJH /NJS | Out-Null
|
||||
}
|
||||
|
||||
SetProgress "Finalising USB drive..." 90
|
||||
Log "Files copied to USB."
|
||||
|
||||
SetProgress "USB write complete ✔" 100
|
||||
Log "USB drive is ready for use."
|
||||
|
||||
$sync["WPFWin11ISOStatusLog"].Dispatcher.Invoke([action]{
|
||||
[System.Windows.MessageBox]::Show(
|
||||
"USB drive created successfully!`n`nYou can now boot from this drive to install Windows 11.",
|
||||
"USB Ready", "OK", "Info")
|
||||
})
|
||||
}
|
||||
catch {
|
||||
Log "ERROR during USB write: $_"
|
||||
$sync["WPFWin11ISOStatusLog"].Dispatcher.Invoke([action]{
|
||||
[System.Windows.MessageBox]::Show(
|
||||
"USB write failed:`n`n$_",
|
||||
"USB Write Error", "OK", "Error")
|
||||
})
|
||||
}
|
||||
finally {
|
||||
Start-Sleep -Milliseconds 800
|
||||
$sync["WPFWin11ISOStatusLog"].Dispatcher.Invoke([action]{
|
||||
$sync.progressBarTextBlock.Text = ""
|
||||
$sync.progressBarTextBlock.ToolTip = ""
|
||||
$sync.ProgressBar.Value = 0
|
||||
$sync["WPFWin11ISOWriteUSBButton"].IsEnabled = $true
|
||||
})
|
||||
}
|
||||
}) | Out-Null
|
||||
|
||||
$script.BeginInvoke() | Out-Null
|
||||
}
|
||||
270
functions/private/Invoke-WinUtilISOScript.ps1
Normal file
270
functions/private/Invoke-WinUtilISOScript.ps1
Normal file
@@ -0,0 +1,270 @@
|
||||
function Invoke-WinUtilISOScript {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Applies the standard WinUtil modifications to a mounted Windows 11 install.wim image.
|
||||
|
||||
.DESCRIPTION
|
||||
Removes bloatware AppX packages, Edge, OneDrive, applies privacy/telemetry
|
||||
registry tweaks, disables sponsored-app delivery, bypasses hardware checks,
|
||||
copies autounattend.xml for local-account OOBE, and deletes unwanted
|
||||
scheduled-task definition files — all against an already-mounted WIM image.
|
||||
|
||||
Mounting and dismounting the WIM is the responsibility of the caller
|
||||
(e.g. Invoke-WinUtilISOModify).
|
||||
|
||||
.PARAMETER ScratchDir
|
||||
Full path to the directory where the Windows image is currently mounted
|
||||
(the "scratchdir"). Example: C:\Temp\WinUtil_Win11ISO_20260222\wim_mount
|
||||
|
||||
.PARAMETER Log
|
||||
Optional ScriptBlock used for progress/status logging.
|
||||
Receives a single [string] message argument.
|
||||
Defaults to Write-Output when not supplied.
|
||||
|
||||
.EXAMPLE
|
||||
Invoke-WinUtilISOScript -ScratchDir "C:\Temp\wim_mount"
|
||||
Invoke-WinUtilISOScript -ScratchDir $mountDir -Log { param($m) Write-Host $m }
|
||||
|
||||
.NOTES
|
||||
Author : Chris Titus @christitustech
|
||||
GitHub : https://github.com/ChrisTitusTech
|
||||
Version : 26.02.22
|
||||
#>
|
||||
param (
|
||||
[Parameter(Mandatory)][string]$ScratchDir,
|
||||
[scriptblock]$Log = { param($m) Write-Output $m }
|
||||
)
|
||||
|
||||
# ── Resolve admin group name (for takeown / icacls) ──────────────────────
|
||||
$adminSID = New-Object System.Security.Principal.SecurityIdentifier('S-1-5-32-544')
|
||||
$adminGroup = $adminSID.Translate([System.Security.Principal.NTAccount])
|
||||
|
||||
# ── Local helpers ─────────────────────────────────────────────────────────
|
||||
function _ISOScript-SetReg {
|
||||
param ([string]$path, [string]$name, [string]$type, [string]$value)
|
||||
try {
|
||||
& reg add $path /v $name /t $type /d $value /f | Out-Null
|
||||
& $Log "Set registry value: $path\$name"
|
||||
} catch {
|
||||
& $Log "Error setting registry value: $_"
|
||||
}
|
||||
}
|
||||
|
||||
function _ISOScript-DelReg {
|
||||
param ([string]$path)
|
||||
try {
|
||||
& reg delete $path /f | Out-Null
|
||||
& $Log "Removed registry key: $path"
|
||||
} catch {
|
||||
& $Log "Error removing registry key: $_"
|
||||
}
|
||||
}
|
||||
|
||||
# ═════════════════════════════════════════════════════════════════════════
|
||||
# 1. Remove provisioned AppX packages
|
||||
# ═════════════════════════════════════════════════════════════════════════
|
||||
& $Log "Removing provisioned AppX packages..."
|
||||
|
||||
$packages = & dism /English "/image:$ScratchDir" /Get-ProvisionedAppxPackages |
|
||||
ForEach-Object {
|
||||
if ($_ -match 'PackageName : (.*)') { $matches[1] }
|
||||
}
|
||||
|
||||
$packagePrefixes = @(
|
||||
'AppUp.IntelManagementandSecurityStatus',
|
||||
'Clipchamp.Clipchamp',
|
||||
'DolbyLaboratories.DolbyAccess',
|
||||
'DolbyLaboratories.DolbyDigitalPlusDecoderOEM',
|
||||
'Microsoft.BingNews',
|
||||
'Microsoft.BingSearch',
|
||||
'Microsoft.BingWeather',
|
||||
'Microsoft.Copilot',
|
||||
'Microsoft.Windows.CrossDevice',
|
||||
'Microsoft.GamingApp',
|
||||
'Microsoft.GetHelp',
|
||||
'Microsoft.Getstarted',
|
||||
'Microsoft.Microsoft3DViewer',
|
||||
'Microsoft.MicrosoftOfficeHub',
|
||||
'Microsoft.MicrosoftSolitaireCollection',
|
||||
'Microsoft.MicrosoftStickyNotes',
|
||||
'Microsoft.MixedReality.Portal',
|
||||
'Microsoft.MSPaint',
|
||||
'Microsoft.Office.OneNote',
|
||||
'Microsoft.OfficePushNotificationUtility',
|
||||
'Microsoft.OutlookForWindows',
|
||||
'Microsoft.Paint',
|
||||
'Microsoft.People',
|
||||
'Microsoft.PowerAutomateDesktop',
|
||||
'Microsoft.SkypeApp',
|
||||
'Microsoft.StartExperiencesApp',
|
||||
'Microsoft.Todos',
|
||||
'Microsoft.Wallet',
|
||||
'Microsoft.Windows.DevHome',
|
||||
'Microsoft.Windows.Copilot',
|
||||
'Microsoft.Windows.Teams',
|
||||
'Microsoft.WindowsAlarms',
|
||||
'Microsoft.WindowsCamera',
|
||||
'microsoft.windowscommunicationsapps',
|
||||
'Microsoft.WindowsFeedbackHub',
|
||||
'Microsoft.WindowsMaps',
|
||||
'Microsoft.WindowsSoundRecorder',
|
||||
'Microsoft.WindowsTerminal',
|
||||
'Microsoft.ZuneMusic',
|
||||
'Microsoft.ZuneVideo',
|
||||
'MicrosoftCorporationII.MicrosoftFamily',
|
||||
'MicrosoftCorporationII.QuickAssist',
|
||||
'MSTeams',
|
||||
'MicrosoftTeams',
|
||||
'Microsoft.549981C3F5F10'
|
||||
)
|
||||
|
||||
$packagesToRemove = $packages | Where-Object {
|
||||
$pkg = $_
|
||||
$packagePrefixes | Where-Object { $pkg -like "*$_*" }
|
||||
}
|
||||
foreach ($package in $packagesToRemove) {
|
||||
& dism /English "/image:$ScratchDir" /Remove-ProvisionedAppxPackage "/PackageName:$package"
|
||||
}
|
||||
|
||||
# ═════════════════════════════════════════════════════════════════════════
|
||||
# 2. Remove Edge
|
||||
# ═════════════════════════════════════════════════════════════════════════
|
||||
& $Log "Removing Edge..."
|
||||
Remove-Item -Path "$ScratchDir\Program Files (x86)\Microsoft\Edge" -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item -Path "$ScratchDir\Program Files (x86)\Microsoft\EdgeUpdate" -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item -Path "$ScratchDir\Program Files (x86)\Microsoft\EdgeCore" -Recurse -Force -ErrorAction SilentlyContinue
|
||||
& takeown /f "$ScratchDir\Windows\System32\Microsoft-Edge-Webview" /r | Out-Null
|
||||
& icacls "$ScratchDir\Windows\System32\Microsoft-Edge-Webview" /grant "$($adminGroup.Value):(F)" /T /C | Out-Null
|
||||
Remove-Item -Path "$ScratchDir\Windows\System32\Microsoft-Edge-Webview" -Recurse -Force -ErrorAction SilentlyContinue
|
||||
|
||||
# ═════════════════════════════════════════════════════════════════════════
|
||||
# 3. Remove OneDrive
|
||||
# ═════════════════════════════════════════════════════════════════════════
|
||||
& $Log "Removing OneDrive..."
|
||||
& takeown /f "$ScratchDir\Windows\System32\OneDriveSetup.exe" | Out-Null
|
||||
& icacls "$ScratchDir\Windows\System32\OneDriveSetup.exe" /grant "$($adminGroup.Value):(F)" /T /C | Out-Null
|
||||
Remove-Item -Path "$ScratchDir\Windows\System32\OneDriveSetup.exe" -Force -ErrorAction SilentlyContinue
|
||||
|
||||
# ═════════════════════════════════════════════════════════════════════════
|
||||
# 4. Registry tweaks
|
||||
# ═════════════════════════════════════════════════════════════════════════
|
||||
& $Log "Loading offline registry hives..."
|
||||
reg load HKLM\zCOMPONENTS "$ScratchDir\Windows\System32\config\COMPONENTS" | Out-Null
|
||||
reg load HKLM\zDEFAULT "$ScratchDir\Windows\System32\config\default" | Out-Null
|
||||
reg load HKLM\zNTUSER "$ScratchDir\Users\Default\ntuser.dat" | Out-Null
|
||||
reg load HKLM\zSOFTWARE "$ScratchDir\Windows\System32\config\SOFTWARE" | Out-Null
|
||||
reg load HKLM\zSYSTEM "$ScratchDir\Windows\System32\config\SYSTEM" | Out-Null
|
||||
|
||||
& $Log "Bypassing system requirements..."
|
||||
_ISOScript-SetReg 'HKLM\zDEFAULT\Control Panel\UnsupportedHardwareNotificationCache' 'SV1' 'REG_DWORD' '0'
|
||||
_ISOScript-SetReg 'HKLM\zDEFAULT\Control Panel\UnsupportedHardwareNotificationCache' 'SV2' 'REG_DWORD' '0'
|
||||
_ISOScript-SetReg 'HKLM\zNTUSER\Control Panel\UnsupportedHardwareNotificationCache' 'SV1' 'REG_DWORD' '0'
|
||||
_ISOScript-SetReg 'HKLM\zNTUSER\Control Panel\UnsupportedHardwareNotificationCache' 'SV2' 'REG_DWORD' '0'
|
||||
_ISOScript-SetReg 'HKLM\zSYSTEM\Setup\LabConfig' 'BypassCPUCheck' 'REG_DWORD' '1'
|
||||
_ISOScript-SetReg 'HKLM\zSYSTEM\Setup\LabConfig' 'BypassRAMCheck' 'REG_DWORD' '1'
|
||||
_ISOScript-SetReg 'HKLM\zSYSTEM\Setup\LabConfig' 'BypassSecureBootCheck' 'REG_DWORD' '1'
|
||||
_ISOScript-SetReg 'HKLM\zSYSTEM\Setup\LabConfig' 'BypassStorageCheck' 'REG_DWORD' '1'
|
||||
_ISOScript-SetReg 'HKLM\zSYSTEM\Setup\LabConfig' 'BypassTPMCheck' 'REG_DWORD' '1'
|
||||
_ISOScript-SetReg 'HKLM\zSYSTEM\Setup\MoSetup' 'AllowUpgradesWithUnsupportedTPMOrCPU' 'REG_DWORD' '1'
|
||||
|
||||
& $Log "Disabling sponsored apps..."
|
||||
_ISOScript-SetReg 'HKLM\zNTUSER\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager' 'OemPreInstalledAppsEnabled' 'REG_DWORD' '0'
|
||||
_ISOScript-SetReg 'HKLM\zNTUSER\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager' 'PreInstalledAppsEnabled' 'REG_DWORD' '0'
|
||||
_ISOScript-SetReg 'HKLM\zNTUSER\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager' 'SilentInstalledAppsEnabled' 'REG_DWORD' '0'
|
||||
_ISOScript-SetReg 'HKLM\zSOFTWARE\Policies\Microsoft\Windows\CloudContent' 'DisableWindowsConsumerFeatures' 'REG_DWORD' '1'
|
||||
_ISOScript-SetReg 'HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager' 'ContentDeliveryAllowed' 'REG_DWORD' '0'
|
||||
_ISOScript-SetReg 'HKLM\zSOFTWARE\Microsoft\PolicyManager\current\device\Start' 'ConfigureStartPins' 'REG_SZ' '{"pinnedList": [{}]}'
|
||||
_ISOScript-SetReg 'HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager' 'FeatureManagementEnabled' 'REG_DWORD' '0'
|
||||
_ISOScript-SetReg 'HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager' 'PreInstalledAppsEverEnabled' 'REG_DWORD' '0'
|
||||
_ISOScript-SetReg 'HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager' 'SoftLandingEnabled' 'REG_DWORD' '0'
|
||||
_ISOScript-SetReg 'HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager' 'SubscribedContentEnabled' 'REG_DWORD' '0'
|
||||
_ISOScript-SetReg 'HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager' 'SubscribedContent-310093Enabled' 'REG_DWORD' '0'
|
||||
_ISOScript-SetReg 'HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager' 'SubscribedContent-338388Enabled' 'REG_DWORD' '0'
|
||||
_ISOScript-SetReg 'HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager' 'SubscribedContent-338389Enabled' 'REG_DWORD' '0'
|
||||
_ISOScript-SetReg 'HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager' 'SubscribedContent-338393Enabled' 'REG_DWORD' '0'
|
||||
_ISOScript-SetReg 'HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager' 'SubscribedContent-353694Enabled' 'REG_DWORD' '0'
|
||||
_ISOScript-SetReg 'HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager' 'SubscribedContent-353696Enabled' 'REG_DWORD' '0'
|
||||
_ISOScript-SetReg 'HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager' 'SystemPaneSuggestionsEnabled' 'REG_DWORD' '0'
|
||||
_ISOScript-SetReg 'HKLM\zSOFTWARE\Policies\Microsoft\PushToInstall' 'DisablePushToInstall' 'REG_DWORD' '1'
|
||||
_ISOScript-SetReg 'HKLM\zSOFTWARE\Policies\Microsoft\MRT' 'DontOfferThroughWUAU' 'REG_DWORD' '1'
|
||||
_ISOScript-DelReg 'HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager\Subscriptions'
|
||||
_ISOScript-DelReg 'HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager\SuggestedApps'
|
||||
_ISOScript-SetReg 'HKLM\zSOFTWARE\Policies\Microsoft\Windows\CloudContent' 'DisableConsumerAccountStateContent' 'REG_DWORD' '1'
|
||||
_ISOScript-SetReg 'HKLM\zSOFTWARE\Policies\Microsoft\Windows\CloudContent' 'DisableCloudOptimizedContent' 'REG_DWORD' '1'
|
||||
|
||||
& $Log "Enabling local accounts on OOBE..."
|
||||
_ISOScript-SetReg 'HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\OOBE' 'BypassNRO' 'REG_DWORD' '1'
|
||||
|
||||
$sysprepDest = "$ScratchDir\Windows\System32\Sysprep\autounattend.xml"
|
||||
Set-Content -Path $sysprepDest -Value $WinUtilAutounattendXml -Encoding UTF8 -Force
|
||||
& $Log "Written autounattend.xml to Sysprep directory."
|
||||
|
||||
& $Log "Disabling reserved storage..."
|
||||
_ISOScript-SetReg 'HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\ReserveManager' 'ShippedWithReserves' 'REG_DWORD' '0'
|
||||
|
||||
& $Log "Disabling BitLocker device encryption..."
|
||||
_ISOScript-SetReg 'HKLM\zSYSTEM\ControlSet001\Control\BitLocker' 'PreventDeviceEncryption' 'REG_DWORD' '1'
|
||||
|
||||
& $Log "Disabling Chat icon..."
|
||||
_ISOScript-SetReg 'HKLM\zSOFTWARE\Policies\Microsoft\Windows\Windows Chat' 'ChatIcon' 'REG_DWORD' '3'
|
||||
_ISOScript-SetReg 'HKLM\zNTUSER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' 'TaskbarMn' 'REG_DWORD' '0'
|
||||
|
||||
& $Log "Removing Edge registry entries..."
|
||||
_ISOScript-DelReg 'HKLM\zSOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge'
|
||||
_ISOScript-DelReg 'HKLM\zSOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge Update'
|
||||
|
||||
& $Log "Disabling OneDrive folder backup..."
|
||||
_ISOScript-SetReg 'HKLM\zSOFTWARE\Policies\Microsoft\Windows\OneDrive' 'DisableFileSyncNGSC' 'REG_DWORD' '1'
|
||||
|
||||
& $Log "Disabling telemetry..."
|
||||
_ISOScript-SetReg 'HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo' 'Enabled' 'REG_DWORD' '0'
|
||||
_ISOScript-SetReg 'HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\Privacy' 'TailoredExperiencesWithDiagnosticDataEnabled' 'REG_DWORD' '0'
|
||||
_ISOScript-SetReg 'HKLM\zNTUSER\Software\Microsoft\Speech_OneCore\Settings\OnlineSpeechPrivacy' 'HasAccepted' 'REG_DWORD' '0'
|
||||
_ISOScript-SetReg 'HKLM\zNTUSER\Software\Microsoft\Input\TIPC' 'Enabled' 'REG_DWORD' '0'
|
||||
_ISOScript-SetReg 'HKLM\zNTUSER\Software\Microsoft\InputPersonalization' 'RestrictImplicitInkCollection' 'REG_DWORD' '1'
|
||||
_ISOScript-SetReg 'HKLM\zNTUSER\Software\Microsoft\InputPersonalization' 'RestrictImplicitTextCollection' 'REG_DWORD' '1'
|
||||
_ISOScript-SetReg 'HKLM\zNTUSER\Software\Microsoft\InputPersonalization\TrainedDataStore' 'HarvestContacts' 'REG_DWORD' '0'
|
||||
_ISOScript-SetReg 'HKLM\zNTUSER\Software\Microsoft\Personalization\Settings' 'AcceptedPrivacyPolicy' 'REG_DWORD' '0'
|
||||
_ISOScript-SetReg 'HKLM\zSOFTWARE\Policies\Microsoft\Windows\DataCollection' 'AllowTelemetry' 'REG_DWORD' '0'
|
||||
_ISOScript-SetReg 'HKLM\zSYSTEM\ControlSet001\Services\dmwappushservice' 'Start' 'REG_DWORD' '4'
|
||||
|
||||
& $Log "Preventing installation of DevHome and Outlook..."
|
||||
_ISOScript-SetReg 'HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Orchestrator\UScheduler_Oobe\OutlookUpdate' 'workCompleted' 'REG_DWORD' '1'
|
||||
_ISOScript-SetReg 'HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Orchestrator\UScheduler\OutlookUpdate' 'workCompleted' 'REG_DWORD' '1'
|
||||
_ISOScript-SetReg 'HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Orchestrator\UScheduler\DevHomeUpdate' 'workCompleted' 'REG_DWORD' '1'
|
||||
_ISOScript-DelReg 'HKLM\zSOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\OutlookUpdate'
|
||||
_ISOScript-DelReg 'HKLM\zSOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\DevHomeUpdate'
|
||||
|
||||
& $Log "Disabling Copilot..."
|
||||
_ISOScript-SetReg 'HKLM\zSOFTWARE\Policies\Microsoft\Windows\WindowsCopilot' 'TurnOffWindowsCopilot' 'REG_DWORD' '1'
|
||||
_ISOScript-SetReg 'HKLM\zSOFTWARE\Policies\Microsoft\Edge' 'HubsSidebarEnabled' 'REG_DWORD' '0'
|
||||
_ISOScript-SetReg 'HKLM\zSOFTWARE\Policies\Microsoft\Windows\Explorer' 'DisableSearchBoxSuggestions' 'REG_DWORD' '1'
|
||||
|
||||
& $Log "Preventing installation of Teams..."
|
||||
_ISOScript-SetReg 'HKLM\zSOFTWARE\Policies\Microsoft\Teams' 'DisableInstallation' 'REG_DWORD' '1'
|
||||
|
||||
& $Log "Preventing installation of new Outlook..."
|
||||
_ISOScript-SetReg 'HKLM\zSOFTWARE\Policies\Microsoft\Windows\Windows Mail' 'PreventRun' 'REG_DWORD' '1'
|
||||
|
||||
& $Log "Unloading offline registry hives..."
|
||||
reg unload HKLM\zCOMPONENTS | Out-Null
|
||||
reg unload HKLM\zDEFAULT | Out-Null
|
||||
reg unload HKLM\zNTUSER | Out-Null
|
||||
reg unload HKLM\zSOFTWARE | Out-Null
|
||||
reg unload HKLM\zSYSTEM | Out-Null
|
||||
|
||||
# ═════════════════════════════════════════════════════════════════════════
|
||||
# 5. Delete scheduled task definition files
|
||||
# ═════════════════════════════════════════════════════════════════════════
|
||||
& $Log "Deleting scheduled task definition files..."
|
||||
$tasksPath = "$ScratchDir\Windows\System32\Tasks"
|
||||
|
||||
Remove-Item "$tasksPath\Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item "$tasksPath\Microsoft\Windows\Customer Experience Improvement Program" -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item "$tasksPath\Microsoft\Windows\Application Experience\ProgramDataUpdater" -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item "$tasksPath\Microsoft\Windows\Chkdsk\Proxy" -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item "$tasksPath\Microsoft\Windows\Windows Error Reporting\QueueReporting" -Force -ErrorAction SilentlyContinue
|
||||
|
||||
& $Log "Scheduled task files deleted."
|
||||
}
|
||||
|
||||
@@ -281,6 +281,7 @@ $commonKeyEvents = {
|
||||
"T" { Invoke-WPFButton "WPFTab2BT"; $keyEventArgs.Handled = $true } # Navigate to Tweaks tab
|
||||
"C" { Invoke-WPFButton "WPFTab3BT"; $keyEventArgs.Handled = $true } # Navigate to Config tab
|
||||
"U" { Invoke-WPFButton "WPFTab4BT"; $keyEventArgs.Handled = $true } # Navigate to Updates tab
|
||||
"W" { Invoke-WPFButton "WPFTab5BT"; $keyEventArgs.Handled = $true } # Navigate to Win11ISO tab
|
||||
}
|
||||
}
|
||||
# Handle Ctrl key combinations for specific actions
|
||||
@@ -531,5 +532,44 @@ $sync["FontScalingApplyButton"].Add_Click({
|
||||
Invoke-WPFPopup -Action "Hide" -Popups @("FontScaling")
|
||||
})
|
||||
|
||||
# ── Win11ISO Tab button handlers ──────────────────────────────────────────────
|
||||
|
||||
$sync["WPFWin11ISOBrowseButton"].Add_Click({
|
||||
Write-Debug "WPFWin11ISOBrowseButton clicked"
|
||||
Invoke-WinUtilISOBrowse
|
||||
})
|
||||
|
||||
$sync["WPFWin11ISODownloadLink"].Add_Click({
|
||||
Write-Debug "WPFWin11ISODownloadLink clicked"
|
||||
Start-Process "https://www.microsoft.com/software-download/windows11"
|
||||
})
|
||||
|
||||
$sync["WPFWin11ISOMountButton"].Add_Click({
|
||||
Write-Debug "WPFWin11ISOMountButton clicked"
|
||||
Invoke-WinUtilISOMountAndVerify
|
||||
})
|
||||
|
||||
$sync["WPFWin11ISOModifyButton"].Add_Click({
|
||||
Write-Debug "WPFWin11ISOModifyButton clicked"
|
||||
Invoke-WinUtilISOModify
|
||||
})
|
||||
|
||||
$sync["WPFWin11ISOExportButton"].Add_Click({
|
||||
Write-Debug "WPFWin11ISOExportButton clicked"
|
||||
Invoke-WinUtilISOExport
|
||||
})
|
||||
|
||||
$sync["WPFWin11ISORefreshUSBButton"].Add_Click({
|
||||
Write-Debug "WPFWin11ISORefreshUSBButton clicked"
|
||||
Invoke-WinUtilISORefreshUSBDrives
|
||||
})
|
||||
|
||||
$sync["WPFWin11ISOWriteUSBButton"].Add_Click({
|
||||
Write-Debug "WPFWin11ISOWriteUSBButton clicked"
|
||||
Invoke-WinUtilISOWriteUSB
|
||||
})
|
||||
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
$sync["Form"].ShowDialog() | out-null
|
||||
Stop-Transcript
|
||||
|
||||
239
tools/autounattend.xml
Normal file
239
tools/autounattend.xml
Normal file
@@ -0,0 +1,239 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Windows 11 Unattended Installation Answer File
|
||||
================================================
|
||||
UNIVERSAL — no modification required before use.
|
||||
|
||||
What this file does automatically:
|
||||
• Installs "Windows 11 Pro" from any standard Microsoft ISO
|
||||
• Bypasses the Microsoft-account OOBE requirement (local account)
|
||||
• Skips the EULA, wireless, and privacy nag screens
|
||||
• Leaves timezone, language, region, and user account to the user
|
||||
at the two short OOBE screens that remain
|
||||
|
||||
What the user is prompted for during first-run (OOBE):
|
||||
1. Region / Language / Keyboard (one screen)
|
||||
2. Who will use this PC? (local account name + password)
|
||||
|
||||
Timezone is set to UTC and can be adjusted after login.
|
||||
Computer name is auto-generated; rename at any time.
|
||||
|
||||
Tested against: Windows 11 Home / Pro / Home Single Language (amd64)
|
||||
Pass order: windowsPE → specialize → oobeSystem
|
||||
-->
|
||||
<unattend xmlns="urn:schemas-microsoft-com:unattend">
|
||||
|
||||
<!-- ═══════════════════════════════════════════════════════════════════
|
||||
PASS 1 — windowsPE
|
||||
Runs inside the installer environment before the OS is laid down.
|
||||
Handles disk layout and image selection only.
|
||||
Locale is intentionally omitted so the installer inherits the
|
||||
language of whichever ISO is being used.
|
||||
═══════════════════════════════════════════════════════════════════════ -->
|
||||
<settings pass="windowsPE">
|
||||
|
||||
<!-- Setup / image selection -->
|
||||
<component name="Microsoft-Windows-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">
|
||||
|
||||
<!-- Disable dynamic updates during setup (keeps installation offline/fast) -->
|
||||
<DynamicUpdate>
|
||||
<Enable>false</Enable>
|
||||
</DynamicUpdate>
|
||||
|
||||
<ImageInstall>
|
||||
<OSImage>
|
||||
<!-- CompactOS saves ~1.5 GB but is slower on spinning drives -->
|
||||
<Compact>false</Compact>
|
||||
<WillShowUI>OnError</WillShowUI>
|
||||
<InstallFrom>
|
||||
<!--
|
||||
Select the edition by NAME rather than by index number.
|
||||
Index numbers vary between ISO builds; the name is stable.
|
||||
Change "Windows 11 Pro" to "Windows 11 Home" etc. if your
|
||||
ISO only contains that edition. To choose interactively,
|
||||
delete this entire <InstallFrom> block.
|
||||
-->
|
||||
<MetaData wcm:action="add">
|
||||
<Key>/IMAGE/NAME</Key>
|
||||
<Value>Windows 11 Pro</Value>
|
||||
</MetaData>
|
||||
</InstallFrom>
|
||||
<!-- InstallTo is omitted — the Windows installer will prompt
|
||||
the user to select the destination disk and partition. -->
|
||||
</OSImage>
|
||||
</ImageInstall>
|
||||
|
||||
<UserData>
|
||||
<AcceptEula>true</AcceptEula>
|
||||
<ProductKey>
|
||||
<!--
|
||||
Leave <Key> absent to use an existing digital licence or
|
||||
to be prompted for one after setup.
|
||||
|
||||
Generic setup keys (allow setup to proceed; do NOT activate):
|
||||
Home : YTMG3-N6DKC-DKB77-7M9GH-8HVX7
|
||||
Home Single Language : 7HNRX-D7KGG-3K4RQ-4WPJ4-YTDFH
|
||||
Pro : VK7JG-NPHTM-C97JM-9MPGT-3V66T
|
||||
Education : YNMGQ-8RYV3-4PGQ3-C8XTP-7CFBY
|
||||
Enterprise : XGVPP-NMH47-7TTHJ-W3FW7-8HV2C
|
||||
-->
|
||||
<WillShowUI>OnError</WillShowUI>
|
||||
</ProductKey>
|
||||
</UserData>
|
||||
|
||||
</component>
|
||||
</settings>
|
||||
|
||||
<!-- ═══════════════════════════════════════════════════════════════════
|
||||
PASS 2 — specialize
|
||||
First boot into the installed OS.
|
||||
Machine-level settings that do not vary by user or region.
|
||||
═══════════════════════════════════════════════════════════════════════ -->
|
||||
<settings pass="specialize">
|
||||
|
||||
<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">
|
||||
|
||||
<!-- Auto-generate a unique computer name. Rename anytime:
|
||||
Settings › System › About › Rename this PC -->
|
||||
<ComputerName>*</ComputerName>
|
||||
|
||||
<!--
|
||||
UTC is the only timezone that is correct everywhere on Earth
|
||||
without knowing where the machine will be used.
|
||||
Windows will auto-adjust to local time once the user sets their
|
||||
region, or they can change it in Settings › Time & Language.
|
||||
-->
|
||||
<TimeZone>UTC</TimeZone>
|
||||
|
||||
<!-- Suppress the Teams/Chat auto-install prompt during setup -->
|
||||
<ConfigureChatAutoInstall>false</ConfigureChatAutoInstall>
|
||||
|
||||
</component>
|
||||
|
||||
<!-- Reduce telemetry to the minimum permitted by the licence.
|
||||
0 = Security (Enterprise/Education only; treated as 1 on other SKUs)
|
||||
1 = Basic / Required diagnostic data ← effective minimum for Home/Pro -->
|
||||
<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>
|
||||
|
||||
</settings>
|
||||
|
||||
<!-- ═══════════════════════════════════════════════════════════════════
|
||||
PASS 3 — oobeSystem
|
||||
Out-of-Box Experience (first-run wizard).
|
||||
|
||||
Screens shown to the user (everything else is suppressed):
|
||||
① Region / Language / Keyboard layout — user picks their locale
|
||||
② Create a local account — user picks name + password
|
||||
|
||||
Screens suppressed automatically:
|
||||
• EULA
|
||||
• "Sign in with Microsoft" / online account
|
||||
• Wi-Fi selection (can be done after login)
|
||||
• "Let Microsoft and apps use your location", Cortana, etc.
|
||||
|
||||
Locale settings are intentionally omitted here so that Windows
|
||||
applies whatever the user selects on screen ①.
|
||||
═══════════════════════════════════════════════════════════════════════ -->
|
||||
<settings pass="oobeSystem">
|
||||
|
||||
<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">
|
||||
|
||||
<OOBE>
|
||||
<!-- Suppress the licence agreement — already accepted in windowsPE -->
|
||||
<HideEULAPage>true</HideEULAPage>
|
||||
|
||||
<!-- KEEP false — this is the screen where the user creates -->
|
||||
<!-- their local account (name + password). Setting it true -->
|
||||
<!-- would skip account creation entirely, leaving only the -->
|
||||
<!-- built-in Administrator account. -->
|
||||
<HideLocalAccountScreen>false</HideLocalAccountScreen>
|
||||
|
||||
<!-- Suppress "Sign in with Microsoft" screens.
|
||||
The user goes straight to local account creation. -->
|
||||
<HideOnlineAccountScreens>true</HideOnlineAccountScreens>
|
||||
|
||||
<!-- Skip Wi-Fi setup — can be connected after first login -->
|
||||
<HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
|
||||
|
||||
<!-- Suppress the privacy / recommended-settings nag screen -->
|
||||
<ProtectYourPC>3</ProtectYourPC>
|
||||
</OOBE>
|
||||
|
||||
<!--
|
||||
UserAccounts and AutoLogon are intentionally absent.
|
||||
The user creates their own account on the OOBE screen above.
|
||||
This is the safest and most universally applicable approach:
|
||||
no hardcoded credentials ship inside the answer file.
|
||||
|
||||
If you want to pre-create an account instead, add:
|
||||
|
||||
<UserAccounts>
|
||||
<LocalAccounts>
|
||||
<LocalAccount wcm:action="add">
|
||||
<Name>YourUsername</Name>
|
||||
<Password>
|
||||
<Value>YourPassword</Value>
|
||||
<PlainText>true</PlainText>
|
||||
</Password>
|
||||
<DisplayName>Your Full Name</DisplayName>
|
||||
<Group>Administrators</Group>
|
||||
</LocalAccount>
|
||||
</LocalAccounts>
|
||||
</UserAccounts>
|
||||
<AutoLogon>
|
||||
<Enabled>true</Enabled>
|
||||
<LogonCount>1</LogonCount>
|
||||
<Username>YourUsername</Username>
|
||||
<Password>
|
||||
<Value>YourPassword</Value>
|
||||
<PlainText>true</PlainText>
|
||||
</Password>
|
||||
</AutoLogon>
|
||||
|
||||
And set HideLocalAccountScreen to true above.
|
||||
-->
|
||||
|
||||
<!--
|
||||
Optional: run a script on first logon.
|
||||
Uncomment and adjust the path/command as needed.
|
||||
|
||||
<FirstLogonCommands>
|
||||
<SynchronousCommand wcm:action="add">
|
||||
<Order>1</Order>
|
||||
<CommandLine>powershell -NoProfile -ExecutionPolicy Bypass -Command "irm https://christitus.com/win | iex"</CommandLine>
|
||||
<Description>Launch WinUtil post-install</Description>
|
||||
<RequiresUserInput>false</RequiresUserInput>
|
||||
</SynchronousCommand>
|
||||
</FirstLogonCommands>
|
||||
-->
|
||||
|
||||
</component>
|
||||
</settings>
|
||||
|
||||
</unattend>
|
||||
@@ -970,6 +970,14 @@
|
||||
</TextBlock>
|
||||
</ToggleButton.Content>
|
||||
</ToggleButton>
|
||||
<ToggleButton Margin="0,0,5,0" Height="{DynamicResource TabButtonHeight}" Width="{DynamicResource TabButtonWidth}"
|
||||
Background="{DynamicResource ButtonWin11ISOBackgroundColor}" Foreground="{DynamicResource ButtonWin11ISOForegroundColor}" FontWeight="Bold" Name="WPFTab5BT">
|
||||
<ToggleButton.Content>
|
||||
<TextBlock FontSize="{DynamicResource TabButtonFontSize}" Background="Transparent" Foreground="{DynamicResource ButtonWin11ISOForegroundColor}">
|
||||
<Underline>W</Underline>in11ISO
|
||||
</TextBlock>
|
||||
</ToggleButton.Content>
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Search Bar and Action Buttons -->
|
||||
@@ -1331,6 +1339,300 @@
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</TabItem>
|
||||
<TabItem Header="Win11ISO" Visibility="Collapsed" Name="WPFTab5">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Margin="{DynamicResource TabContentMargin}">
|
||||
<Grid Background="Transparent" Name="Win11ISOPanel">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/> <!-- Step 1: Select ISO -->
|
||||
<RowDefinition Height="Auto"/> <!-- Step 2: Mount & Verify -->
|
||||
<RowDefinition Height="Auto"/> <!-- Step 3: Modify install.wim -->
|
||||
<RowDefinition Height="Auto"/> <!-- Step 4: Output Options -->
|
||||
<RowDefinition Height="Auto"/> <!-- Log / Status -->
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- ═══════════════════════════════════════════════════════════ -->
|
||||
<!-- STEP 1 : Select Windows 11 ISO -->
|
||||
<!-- ═══════════════════════════════════════════════════════════ -->
|
||||
<Border Grid.Row="0" Style="{StaticResource BorderStyle}">
|
||||
<Grid Margin="5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Left: File Selector -->
|
||||
<StackPanel Grid.Column="0" Margin="5,5,15,5">
|
||||
<TextBlock FontSize="{DynamicResource FontSize}" FontWeight="Bold"
|
||||
Foreground="{DynamicResource MainForegroundColor}" Margin="0,0,0,8">
|
||||
Step 1 — Select Windows 11 ISO
|
||||
</TextBlock>
|
||||
<TextBlock FontSize="{DynamicResource FontSize}" Foreground="{DynamicResource MainForegroundColor}"
|
||||
TextWrapping="Wrap" Margin="0,0,0,12">
|
||||
Browse to your locally saved Windows 11 ISO file. Only official ISOs
|
||||
downloaded from Microsoft are supported.
|
||||
</TextBlock>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox Grid.Column="0"
|
||||
Name="WPFWin11ISOPath"
|
||||
IsReadOnly="True"
|
||||
VerticalAlignment="Center"
|
||||
Padding="6,4"
|
||||
Margin="0,0,6,0"
|
||||
Text="No ISO selected..."
|
||||
Foreground="{DynamicResource MainForegroundColor}"
|
||||
Background="{DynamicResource MainBackgroundColor}"/>
|
||||
<Button Grid.Column="1"
|
||||
Name="WPFWin11ISOBrowseButton"
|
||||
Content="Browse…"
|
||||
Width="Auto" Padding="12,0"
|
||||
Height="{DynamicResource ButtonHeight}"/>
|
||||
</Grid>
|
||||
<TextBlock Name="WPFWin11ISOFileInfo"
|
||||
FontSize="{DynamicResource FontSize}"
|
||||
Foreground="{DynamicResource MainForegroundColor}"
|
||||
Margin="0,8,0,0"
|
||||
TextWrapping="Wrap"
|
||||
Visibility="Collapsed"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Right: Download guidance -->
|
||||
<Border Grid.Column="1"
|
||||
Background="{DynamicResource MainBackgroundColor}"
|
||||
BorderBrush="{DynamicResource BorderColor}"
|
||||
BorderThickness="1" CornerRadius="5"
|
||||
Margin="5" Padding="15">
|
||||
<StackPanel>
|
||||
<TextBlock FontSize="{DynamicResource FontSize}" FontWeight="Bold"
|
||||
Foreground="OrangeRed" Margin="0,0,0,10">
|
||||
⚠ You must use an official Microsoft ISO
|
||||
</TextBlock>
|
||||
<TextBlock FontSize="{DynamicResource FontSize}"
|
||||
Foreground="{DynamicResource MainForegroundColor}"
|
||||
TextWrapping="Wrap" Margin="0,0,0,8">
|
||||
Download the Windows 11 ISO directly from Microsoft.com.
|
||||
Third-party, pre-modified, or unofficial images are not supported
|
||||
and may produce broken results.
|
||||
</TextBlock>
|
||||
<TextBlock FontSize="{DynamicResource FontSize}"
|
||||
Foreground="{DynamicResource MainForegroundColor}"
|
||||
TextWrapping="Wrap" Margin="0,0,0,6">
|
||||
On the Microsoft download page, choose:
|
||||
</TextBlock>
|
||||
<TextBlock FontSize="{DynamicResource FontSize}"
|
||||
Foreground="{DynamicResource MainForegroundColor}"
|
||||
TextWrapping="Wrap" Margin="12,0,0,12">
|
||||
• Edition : Windows 11
|
||||
<LineBreak/>• Language : your preferred language
|
||||
<LineBreak/>• Architecture : 64-bit (x64)
|
||||
</TextBlock>
|
||||
<Button Name="WPFWin11ISODownloadLink"
|
||||
Content="Open Microsoft Download Page"
|
||||
HorizontalAlignment="Left"
|
||||
Width="Auto" Padding="12,0"
|
||||
Height="{DynamicResource ButtonHeight}"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- ═══════════════════════════════════════════════════════════ -->
|
||||
<!-- STEP 2 : Mount & Verify ISO -->
|
||||
<!-- ═══════════════════════════════════════════════════════════ -->
|
||||
<Border Grid.Row="1"
|
||||
Name="WPFWin11ISOMountSection"
|
||||
Style="{StaticResource BorderStyle}"
|
||||
Visibility="Collapsed">
|
||||
<Grid Margin="5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel Grid.Column="0" Margin="0,0,20,0" VerticalAlignment="Top">
|
||||
<TextBlock FontSize="{DynamicResource FontSize}" FontWeight="Bold"
|
||||
Foreground="{DynamicResource MainForegroundColor}" Margin="0,0,0,8">
|
||||
Step 2 — Mount & Verify ISO
|
||||
</TextBlock>
|
||||
<TextBlock FontSize="{DynamicResource FontSize}"
|
||||
Foreground="{DynamicResource MainForegroundColor}"
|
||||
TextWrapping="Wrap" Margin="0,0,0,12" MaxWidth="320">
|
||||
Mount the ISO and confirm it contains a valid Windows 11
|
||||
install.wim before any modifications are made.
|
||||
</TextBlock>
|
||||
<Button Name="WPFWin11ISOMountButton"
|
||||
Content="Mount & Verify ISO"
|
||||
HorizontalAlignment="Left"
|
||||
Width="Auto" Padding="12,0"
|
||||
Height="{DynamicResource ButtonHeight}"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Verification results panel -->
|
||||
<Border Grid.Column="1"
|
||||
Name="WPFWin11ISOVerifyResultPanel"
|
||||
Background="{DynamicResource MainBackgroundColor}"
|
||||
BorderBrush="{DynamicResource BorderColor}"
|
||||
BorderThickness="1" CornerRadius="5"
|
||||
Padding="12" Margin="0,0,0,0"
|
||||
Visibility="Collapsed">
|
||||
<StackPanel>
|
||||
<TextBlock Name="WPFWin11ISOMountDriveLetter"
|
||||
FontSize="{DynamicResource FontSize}"
|
||||
Foreground="{DynamicResource MainForegroundColor}"
|
||||
Margin="0,0,0,4"/>
|
||||
<TextBlock Name="WPFWin11ISOArchLabel"
|
||||
FontSize="{DynamicResource FontSize}"
|
||||
Foreground="{DynamicResource MainForegroundColor}"
|
||||
Margin="0,0,0,4"/>
|
||||
<TextBlock FontSize="{DynamicResource FontSize}" FontWeight="Bold"
|
||||
Foreground="{DynamicResource MainForegroundColor}"
|
||||
Margin="0,6,0,4">
|
||||
Available Editions:
|
||||
</TextBlock>
|
||||
<TextBlock Name="WPFWin11ISOEditionList"
|
||||
FontSize="{DynamicResource FontSize}"
|
||||
Foreground="{DynamicResource MainForegroundColor}"
|
||||
TextWrapping="Wrap"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- ═══════════════════════════════════════════════════════════ -->
|
||||
<!-- STEP 3 : Modify install.wim -->
|
||||
<!-- ═══════════════════════════════════════════════════════════ -->
|
||||
<Border Grid.Row="2"
|
||||
Name="WPFWin11ISOModifySection"
|
||||
Style="{StaticResource BorderStyle}"
|
||||
Visibility="Collapsed">
|
||||
<StackPanel Margin="5">
|
||||
<TextBlock FontSize="{DynamicResource FontSize}" FontWeight="Bold"
|
||||
Foreground="{DynamicResource MainForegroundColor}" Margin="0,0,0,8">
|
||||
Step 3 — Modify install.wim
|
||||
</TextBlock>
|
||||
<TextBlock FontSize="{DynamicResource FontSize}"
|
||||
Foreground="{DynamicResource MainForegroundColor}"
|
||||
TextWrapping="Wrap" Margin="0,0,0,12">
|
||||
The ISO contents will be extracted to a temporary working directory,
|
||||
install.wim will be modified (components removed, tweaks applied),
|
||||
and the result will be repackaged. This process may take several minutes
|
||||
depending on your hardware.
|
||||
</TextBlock>
|
||||
<Button Name="WPFWin11ISOModifyButton"
|
||||
Content="Run install.wim Modification"
|
||||
HorizontalAlignment="Left"
|
||||
Width="Auto" Padding="12,0"
|
||||
Height="{DynamicResource ButtonHeight}"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- ═══════════════════════════════════════════════════════════ -->
|
||||
<!-- STEP 4 : Output Options -->
|
||||
<!-- ═══════════════════════════════════════════════════════════ -->
|
||||
<Border Grid.Row="3"
|
||||
Name="WPFWin11ISOOutputSection"
|
||||
Style="{StaticResource BorderStyle}"
|
||||
Visibility="Collapsed">
|
||||
<StackPanel Margin="5">
|
||||
<TextBlock FontSize="{DynamicResource FontSize}" FontWeight="Bold"
|
||||
Foreground="{DynamicResource MainForegroundColor}" Margin="0,0,0,12">
|
||||
Step 4 — Output: What would you like to do with the modified ISO?
|
||||
</TextBlock>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Option 1: Export to ISO -->
|
||||
<Border Grid.Column="0" Style="{StaticResource BorderStyle}">
|
||||
<StackPanel>
|
||||
<Button Name="WPFWin11ISOExportButton"
|
||||
Content="1 — Export to ISO"
|
||||
HorizontalAlignment="Stretch"
|
||||
Width="Auto" Padding="12,0"
|
||||
Height="{DynamicResource ButtonHeight}"
|
||||
Margin="0,0,0,10"/>
|
||||
<TextBlock FontSize="{DynamicResource FontSize}"
|
||||
Foreground="{DynamicResource MainForegroundColor}"
|
||||
TextWrapping="Wrap">
|
||||
Save the modified content as a new bootable ISO file.
|
||||
You can store it, use it in a virtual machine, or later
|
||||
burn it to USB with any tool of your choice.
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- Option 2: Erase & Write to USB -->
|
||||
<Border Grid.Column="1" Style="{StaticResource BorderStyle}">
|
||||
<StackPanel>
|
||||
<!-- USB drive selector row -->
|
||||
<Grid Margin="0,0,0,8">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<ComboBox Grid.Column="0"
|
||||
Name="WPFWin11ISOUSBDriveComboBox"
|
||||
Foreground="{DynamicResource MainForegroundColor}"
|
||||
Background="{DynamicResource MainBackgroundColor}"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0,0,6,0"/>
|
||||
<Button Grid.Column="1"
|
||||
Name="WPFWin11ISORefreshUSBButton"
|
||||
Content="↻ Refresh"
|
||||
Width="Auto" Padding="8,0"
|
||||
Height="{DynamicResource ButtonHeight}"/>
|
||||
</Grid>
|
||||
<Button Name="WPFWin11ISOWriteUSBButton"
|
||||
Content="2 — Erase & Write to USB"
|
||||
Foreground="OrangeRed"
|
||||
HorizontalAlignment="Stretch"
|
||||
Width="Auto" Padding="12,0"
|
||||
Height="{DynamicResource ButtonHeight}"
|
||||
Margin="0,0,0,10"/>
|
||||
<TextBlock FontSize="{DynamicResource FontSize}"
|
||||
Foreground="{DynamicResource MainForegroundColor}"
|
||||
TextWrapping="Wrap">
|
||||
<Run FontWeight="Bold" Foreground="OrangeRed">!! All data on the selected USB drive will be erased !!</Run>
|
||||
<LineBreak/>
|
||||
Select a removable USB drive above, then click the button
|
||||
to write the modified Windows 11 installation directly to it.
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- ═══════════════════════════════════════════════════════════ -->
|
||||
<!-- Status / Log Output -->
|
||||
<!-- ═══════════════════════════════════════════════════════════ -->
|
||||
<Border Grid.Row="4" Style="{StaticResource BorderStyle}">
|
||||
<StackPanel>
|
||||
<TextBlock FontSize="{DynamicResource FontSize}" FontWeight="Bold"
|
||||
Foreground="{DynamicResource MainForegroundColor}" Margin="0,0,0,6">
|
||||
Status Log
|
||||
</TextBlock>
|
||||
<TextBox Name="WPFWin11ISOStatusLog"
|
||||
IsReadOnly="True"
|
||||
TextWrapping="Wrap"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
Height="140" Padding="6"
|
||||
Background="{DynamicResource MainBackgroundColor}"
|
||||
Foreground="{DynamicResource MainForegroundColor}"
|
||||
BorderBrush="{DynamicResource BorderColor}"
|
||||
BorderThickness="1"
|
||||
Text="Ready. Please select a Windows 11 ISO to begin."/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
Reference in New Issue
Block a user