mirror of
https://github.com/ChrisTitusTech/winutil
synced 2026-04-06 06:38:31 +00:00
Compare commits
2 Commits
26.02.24
...
14ad9f7fea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
14ad9f7fea | ||
|
|
52afab2252 |
@@ -124,7 +124,15 @@ function Invoke-WinUtilISOMountAndVerify {
|
||||
[void]$sync["WPFWin11ISOEditionComboBox"].Items.Add("$($img.ImageIndex): $($img.ImageName)")
|
||||
}
|
||||
if ($sync["WPFWin11ISOEditionComboBox"].Items.Count -gt 0) {
|
||||
$sync["WPFWin11ISOEditionComboBox"].SelectedIndex = 0
|
||||
# Default to Windows 11 Pro; fall back to first item if not found
|
||||
$proIndex = -1
|
||||
for ($i = 0; $i -lt $sync["WPFWin11ISOEditionComboBox"].Items.Count; $i++) {
|
||||
if ($sync["WPFWin11ISOEditionComboBox"].Items[$i] -match "Windows 11 Pro(?![\w ])") {
|
||||
$proIndex = $i
|
||||
break
|
||||
}
|
||||
}
|
||||
$sync["WPFWin11ISOEditionComboBox"].SelectedIndex = if ($proIndex -ge 0) { $proIndex } else { 0 }
|
||||
}
|
||||
})
|
||||
$sync["WPFWin11ISOVerifyResultPanel"].Visibility = "Visible"
|
||||
@@ -513,11 +521,17 @@ function Invoke-WinUtilISOExport {
|
||||
|
||||
$outputISO = $dlg.FileName
|
||||
Write-Win11ISOLog "Exporting to ISO: $outputISO"
|
||||
|
||||
Set-WinUtilProgressBar -Label "Building ISO..." -Percent 10
|
||||
|
||||
# Locate oscdimg.exe (Windows ADK)
|
||||
# Locate oscdimg.exe (Windows ADK or winget per-user install)
|
||||
$oscdimg = Get-ChildItem "C:\Program Files (x86)\Windows Kits" -Recurse -Filter "oscdimg.exe" -ErrorAction SilentlyContinue |
|
||||
Select-Object -First 1 -ExpandProperty FullName
|
||||
if (-not $oscdimg) {
|
||||
$oscdimg = Get-ChildItem "$env:LOCALAPPDATA\Microsoft\WinGet\Packages" -Recurse -Filter "oscdimg.exe" -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.FullName -match 'Microsoft\.OSCDIMG' } |
|
||||
Select-Object -First 1 -ExpandProperty FullName
|
||||
}
|
||||
|
||||
if (-not $oscdimg) {
|
||||
Write-Win11ISOLog "oscdimg.exe not found. Attempting to install via winget..."
|
||||
@@ -526,8 +540,9 @@ function Invoke-WinUtilISOExport {
|
||||
$winget = Get-Command winget -ErrorAction Stop
|
||||
$result = & $winget install -e --id Microsoft.OSCDIMG --accept-package-agreements --accept-source-agreements 2>&1
|
||||
Write-Win11ISOLog "winget output: $result"
|
||||
# Re-scan for oscdimg after install
|
||||
$oscdimg = Get-ChildItem "C:\Program Files (x86)\Windows Kits" -Recurse -Filter "oscdimg.exe" -ErrorAction SilentlyContinue |
|
||||
# Re-scan after install
|
||||
$oscdimg = Get-ChildItem "$env:LOCALAPPDATA\Microsoft\WinGet\Packages" -Recurse -Filter "oscdimg.exe" -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.FullName -match 'Microsoft\.OSCDIMG' } |
|
||||
Select-Object -First 1 -ExpandProperty FullName
|
||||
} catch {
|
||||
Write-Win11ISOLog "winget not available or install failed: $_"
|
||||
@@ -559,7 +574,31 @@ function Invoke-WinUtilISOExport {
|
||||
|
||||
try {
|
||||
Write-Win11ISOLog "Running oscdimg..."
|
||||
$proc = Start-Process -FilePath $oscdimg -ArgumentList $oscdimgArgs -Wait -PassThru -NoNewWindow
|
||||
$psi = [System.Diagnostics.ProcessStartInfo]::new()
|
||||
$psi.FileName = $oscdimg
|
||||
$psi.Arguments = $oscdimgArgs -join " "
|
||||
$psi.RedirectStandardOutput = $true
|
||||
$psi.RedirectStandardError = $true
|
||||
$psi.UseShellExecute = $false
|
||||
$psi.CreateNoWindow = $true
|
||||
|
||||
$proc = [System.Diagnostics.Process]::new()
|
||||
$proc.StartInfo = $psi
|
||||
$proc.Start() | Out-Null
|
||||
|
||||
# Stream stdout and stderr line-by-line to the status log
|
||||
$stdoutTask = $proc.StandardOutput.ReadToEndAsync()
|
||||
$stderrTask = $proc.StandardError.ReadToEndAsync()
|
||||
$proc.WaitForExit()
|
||||
[System.Threading.Tasks.Task]::WaitAll($stdoutTask, $stderrTask)
|
||||
|
||||
foreach ($line in ($stdoutTask.Result -split "`r?`n")) {
|
||||
if ($line.Trim()) { Write-Win11ISOLog $line }
|
||||
}
|
||||
foreach ($line in ($stderrTask.Result -split "`r?`n")) {
|
||||
if ($line.Trim()) { Write-Win11ISOLog "[stderr]$line" }
|
||||
}
|
||||
|
||||
if ($proc.ExitCode -eq 0) {
|
||||
Set-WinUtilProgressBar -Label "ISO exported ✔" -Percent 100
|
||||
Write-Win11ISOLog "ISO exported successfully: $outputISO"
|
||||
|
||||
@@ -7,9 +7,8 @@ function Invoke-WinUtilISOScript {
|
||||
Performs the following operations against an already-mounted WIM image:
|
||||
|
||||
1. Removes provisioned AppX bloatware packages via DISM.
|
||||
2. Deletes Microsoft Edge program files.
|
||||
3. Removes OneDriveSetup.exe from the system image.
|
||||
4. Loads offline registry hives (COMPONENTS, DEFAULT, NTUSER, SOFTWARE, SYSTEM)
|
||||
2. Removes OneDriveSetup.exe from the system image.
|
||||
3. Loads offline registry hives (COMPONENTS, DEFAULT, NTUSER, SOFTWARE, SYSTEM)
|
||||
and applies the following tweaks:
|
||||
- Bypasses hardware requirement checks (CPU, RAM, SecureBoot, Storage, TPM).
|
||||
- Disables sponsored-app delivery and ContentDeliveryManager features.
|
||||
@@ -19,14 +18,13 @@ function Invoke-WinUtilISOScript {
|
||||
- Disables reserved storage.
|
||||
- Disables BitLocker device encryption.
|
||||
- Hides the Chat (Teams) taskbar icon.
|
||||
- Removes Edge uninstall registry entries.
|
||||
- Disables OneDrive folder backup (KFM).
|
||||
- Disables telemetry, advertising ID, and input personalization.
|
||||
- Blocks post-install delivery of DevHome, Outlook, and Teams.
|
||||
- Disables Windows Copilot.
|
||||
- Disables Windows Update during OOBE.
|
||||
5. Deletes unwanted scheduled-task XML definition files (CEIP, Appraiser, etc.).
|
||||
6. Removes the support\ folder from the ISO contents directory (if supplied).
|
||||
4. Deletes unwanted scheduled-task XML definition files (CEIP, Appraiser, etc.).
|
||||
5. Removes the support\ folder from the ISO contents directory (if supplied).
|
||||
|
||||
Mounting and dismounting the WIM is the responsibility of the caller
|
||||
(e.g. Invoke-WinUtilISO).
|
||||
@@ -122,7 +120,6 @@ function Invoke-WinUtilISOScript {
|
||||
'Microsoft.BingWeather',
|
||||
'Microsoft.Copilot',
|
||||
'Microsoft.Windows.CrossDevice',
|
||||
'Microsoft.GamingApp',
|
||||
'Microsoft.GetHelp',
|
||||
'Microsoft.Getstarted',
|
||||
'Microsoft.Microsoft3DViewer',
|
||||
@@ -167,13 +164,7 @@ function Invoke-WinUtilISOScript {
|
||||
}
|
||||
|
||||
# ═════════════════════════════════════════════════════════════════════════
|
||||
# 2. Remove Edge
|
||||
# ═════════════════════════════════════════════════════════════════════════
|
||||
& $Log "Removing Edge..."
|
||||
Remove-Item -Path "$ScratchDir\Program Files (x86)\Microsoft\Edge" -Recurse -Force -ErrorAction SilentlyContinue
|
||||
|
||||
# ═════════════════════════════════════════════════════════════════════════
|
||||
# 3. Remove OneDrive
|
||||
# 2. Remove OneDrive
|
||||
# ═════════════════════════════════════════════════════════════════════════
|
||||
& $Log "Removing OneDrive..."
|
||||
& takeown /f "$ScratchDir\Windows\System32\OneDriveSetup.exe" | Out-Null
|
||||
@@ -181,7 +172,7 @@ function Invoke-WinUtilISOScript {
|
||||
Remove-Item -Path "$ScratchDir\Windows\System32\OneDriveSetup.exe" -Force -ErrorAction SilentlyContinue
|
||||
|
||||
# ═════════════════════════════════════════════════════════════════════════
|
||||
# 4. Registry tweaks
|
||||
# 3. Registry tweaks
|
||||
# ═════════════════════════════════════════════════════════════════════════
|
||||
& $Log "Loading offline registry hives..."
|
||||
reg load HKLM\zCOMPONENTS "$ScratchDir\Windows\System32\config\COMPONENTS"
|
||||
@@ -258,10 +249,6 @@ function Invoke-WinUtilISOScript {
|
||||
Set-ISOScriptReg 'HKLM\zSOFTWARE\Policies\Microsoft\Windows\Windows Chat' 'ChatIcon' 'REG_DWORD' '3'
|
||||
Set-ISOScriptReg 'HKLM\zNTUSER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' 'TaskbarMn' 'REG_DWORD' '0'
|
||||
|
||||
& $Log "Removing Edge registry entries..."
|
||||
Remove-ISOScriptReg 'HKLM\zSOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge'
|
||||
Remove-ISOScriptReg 'HKLM\zSOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge Update'
|
||||
|
||||
& $Log "Disabling OneDrive folder backup..."
|
||||
Set-ISOScriptReg 'HKLM\zSOFTWARE\Policies\Microsoft\Windows\OneDrive' 'DisableFileSyncNGSC' 'REG_DWORD' '1'
|
||||
|
||||
@@ -291,7 +278,18 @@ function Invoke-WinUtilISOScript {
|
||||
|
||||
& $Log "Disabling Windows Update during OOBE (re-enabled on first logon via FirstLogon.ps1)..."
|
||||
Set-ISOScriptReg 'HKLM\zSOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU' 'NoAutoUpdate' 'REG_DWORD' '1'
|
||||
Set-ISOScriptReg 'HKLM\zSOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU' 'AUOptions' 'REG_DWORD' '1'
|
||||
Set-ISOScriptReg 'HKLM\zSOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU' 'UseWUServer' 'REG_DWORD' '1'
|
||||
Set-ISOScriptReg 'HKLM\zSOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' 'DisableWindowsUpdateAccess' 'REG_DWORD' '1'
|
||||
Set-ISOScriptReg 'HKLM\zSOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' 'WUServer' 'REG_SZ' 'http://localhost:8080'
|
||||
Set-ISOScriptReg 'HKLM\zSOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' 'WUStatusServer' 'REG_SZ' 'http://localhost:8080'
|
||||
Set-ISOScriptReg 'HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Orchestrator\UScheduler_Oobe\WindowsUpdate' 'workCompleted' 'REG_DWORD' '1'
|
||||
Remove-ISOScriptReg 'HKLM\zSOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\WindowsUpdate'
|
||||
Set-ISOScriptReg 'HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config' 'DODownloadMode' 'REG_DWORD' '0'
|
||||
Set-ISOScriptReg 'HKLM\zSYSTEM\ControlSet001\Services\BITS' 'Start' 'REG_DWORD' '4'
|
||||
Set-ISOScriptReg 'HKLM\zSYSTEM\ControlSet001\Services\wuauserv' 'Start' 'REG_DWORD' '4'
|
||||
Set-ISOScriptReg 'HKLM\zSYSTEM\ControlSet001\Services\UsoSvc' 'Start' 'REG_DWORD' '4'
|
||||
Set-ISOScriptReg 'HKLM\zSYSTEM\ControlSet001\Services\WaaSMedicSvc' 'Start' 'REG_DWORD' '4'
|
||||
|
||||
& $Log "Preventing installation of Teams..."
|
||||
Set-ISOScriptReg 'HKLM\zSOFTWARE\Policies\Microsoft\Teams' 'DisableInstallation' 'REG_DWORD' '1'
|
||||
@@ -307,7 +305,7 @@ function Invoke-WinUtilISOScript {
|
||||
reg unload HKLM\zSYSTEM
|
||||
|
||||
# ═════════════════════════════════════════════════════════════════════════
|
||||
# 5. Delete scheduled task definition files
|
||||
# 4. Delete scheduled task definition files
|
||||
# ═════════════════════════════════════════════════════════════════════════
|
||||
& $Log "Deleting scheduled task definition files..."
|
||||
$tasksPath = "$ScratchDir\Windows\System32\Tasks"
|
||||
@@ -317,11 +315,17 @@ function Invoke-WinUtilISOScript {
|
||||
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
|
||||
Remove-Item "$tasksPath\Microsoft\Windows\InstallService" -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item "$tasksPath\Microsoft\Windows\UpdateOrchestrator" -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item "$tasksPath\Microsoft\Windows\UpdateAssistant" -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item "$tasksPath\Microsoft\Windows\WaaSMedic" -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item "$tasksPath\Microsoft\Windows\WindowsUpdate" -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item "$tasksPath\Microsoft\WindowsUpdate" -Recurse -Force -ErrorAction SilentlyContinue
|
||||
|
||||
& $Log "Scheduled task files deleted."
|
||||
|
||||
# ═════════════════════════════════════════════════════════════════════════
|
||||
# 6. Remove ISO support folder (fresh-install only; not needed)
|
||||
# 5. Remove ISO support folder (fresh-install only; not needed)
|
||||
# ═════════════════════════════════════════════════════════════════════════
|
||||
if ($ISOContentsDir -and (Test-Path $ISOContentsDir)) {
|
||||
& $Log "Removing ISO support\ folder..."
|
||||
|
||||
@@ -449,8 +449,17 @@ $scripts = @(
|
||||
) -Force -ErrorAction 'SilentlyContinue' -Verbose;
|
||||
};
|
||||
{
|
||||
reg.exe delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v NoAutoUpdate /f;
|
||||
reg.exe delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DisableWindowsUpdateAccess /f;
|
||||
reg.exe delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v NoAutoUpdate /f;
|
||||
reg.exe delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v AUOptions /f;
|
||||
reg.exe delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v UseWUServer /f;
|
||||
reg.exe delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DisableWindowsUpdateAccess /f;
|
||||
reg.exe delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v WUServer /f;
|
||||
reg.exe delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v WUStatusServer /f;
|
||||
reg.exe delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" /v DODownloadMode /f;
|
||||
reg.exe add "HKLM\SYSTEM\CurrentControlSet\Services\BITS" /v Start /t REG_DWORD /d 3 /f;
|
||||
reg.exe add "HKLM\SYSTEM\CurrentControlSet\Services\wuauserv" /v Start /t REG_DWORD /d 3 /f;
|
||||
reg.exe add "HKLM\SYSTEM\CurrentControlSet\Services\UsoSvc" /v Start /t REG_DWORD /d 2 /f;
|
||||
reg.exe add "HKLM\SYSTEM\CurrentControlSet\Services\WaaSMedicSvc" /v Start /t REG_DWORD /d 3 /f;
|
||||
};
|
||||
{
|
||||
$recallFeature = Get-WindowsOptionalFeature -Online -ErrorAction SilentlyContinue | Where-Object { $_.State -eq 'Enabled' -and $_.FeatureName -like 'Recall' };
|
||||
|
||||
Reference in New Issue
Block a user