From 41ac93d09ae79bb761964b9cdb6ed7f4a0908fe3 Mon Sep 17 00:00:00 2001 From: CodingWonders <101426328+CodingWonders@users.noreply.github.com> Date: Mon, 12 Aug 2024 22:03:38 +0200 Subject: [PATCH 1/4] Add quotes to paths (#2552) Fixes reported issues about paths with spaces --- functions/private/Invoke-MicroWin-Helper.ps1 | 6 +++--- functions/public/Invoke-WPFGetIso.ps1 | 8 ++++---- functions/public/Invoke-WPFMicrowin.ps1 | 12 ++++++------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/functions/private/Invoke-MicroWin-Helper.ps1 b/functions/private/Invoke-MicroWin-Helper.ps1 index d0cd1c9e..ece18de9 100644 --- a/functions/private/Invoke-MicroWin-Helper.ps1 +++ b/functions/private/Invoke-MicroWin-Helper.ps1 @@ -157,7 +157,7 @@ function Remove-ProvisionedPackages([switch]$keepSecurity = $false) { $status = "Removing Provisioned $($appx.PackageName)" Write-Progress -Activity "Removing Provisioned Apps" -Status $status -PercentComplete ($counter++/$appxProvisionedPackages.Count*100) try { - Remove-AppxProvisionedPackage -Path $scratchDir -PackageName $appx.PackageName -ErrorAction SilentlyContinue + Remove-AppxProvisionedPackage -Path "$scratchDir" -PackageName $appx.PackageName -ErrorAction SilentlyContinue } catch { Write-Host "Application $($appx.PackageName) could not be removed" continue @@ -175,9 +175,9 @@ function Copy-ToUSB([string]$fileToCopy) { $destinationPath = "$($volume.DriveLetter):\" #Copy-Item -Path $fileToCopy -Destination $destinationPath -Force # Get the total size of the file - $totalSize = (Get-Item $fileToCopy).length + $totalSize = (Get-Item "$fileToCopy").length - Copy-Item -Path $fileToCopy -Destination $destinationPath -Verbose -Force -Recurse -Container -PassThru | + Copy-Item -Path "$fileToCopy" -Destination "$destinationPath" -Verbose -Force -Recurse -Container -PassThru | ForEach-Object { # Calculate the percentage completed $completed = ($_.BytesTransferred / $totalSize) * 100 diff --git a/functions/public/Invoke-WPFGetIso.ps1 b/functions/public/Invoke-WPFGetIso.ps1 index 2db534c7..9a0b7455 100644 --- a/functions/public/Invoke-WPFGetIso.ps1 +++ b/functions/public/Invoke-WPFGetIso.ps1 @@ -76,7 +76,7 @@ function Invoke-WPFGetIso { } Write-Host "File path $($filePath)" - if (-not (Test-Path -Path $filePath -PathType Leaf)) { + if (-not (Test-Path -Path "$filePath" -PathType Leaf)) { $msg = "File you've chosen doesn't exist" [System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Error) return @@ -85,7 +85,7 @@ function Invoke-WPFGetIso { Set-WinUtilTaskbaritem -state "Indeterminate" -overlay "logo" # Detect the file size of the ISO and compare it with the free space of the system drive - $isoSize = (Get-Item -Path $filePath).Length + $isoSize = (Get-Item -Path "$filePath").Length Write-Debug "Size of ISO file: $($isoSize) bytes" # Use this procedure to get the free space of the drive depending on where the user profile folder is stored. # This is done to guarantee a dynamic solution, as the installation drive may be mounted to a letter different than C @@ -122,7 +122,7 @@ function Invoke-WPFGetIso { # there is probably a better way of doing this, I don't have time to figure this out $sync.MicrowinIsoDrive.Text = $driveLetter - $mountedISOPath = (Split-Path -Path $filePath) + $mountedISOPath = (Split-Path -Path "$filePath") if ($sync.MicrowinScratchDirBox.Text.Trim() -eq "Scratch") { $sync.MicrowinScratchDirBox.Text ="" } @@ -186,7 +186,7 @@ function Invoke-WPFGetIso { $wimFile = "$mountDir\sources\install.wim" Write-Host "Getting image information $wimFile" - if ((-not (Test-Path -Path $wimFile -PathType Leaf)) -and (-not (Test-Path -Path $wimFile.Replace(".wim", ".esd").Trim() -PathType Leaf))) { + if ((-not (Test-Path -Path "$wimFile" -PathType Leaf)) -and (-not (Test-Path -Path "$($wimFile.Replace(".wim", ".esd").Trim())" -PathType Leaf))) { $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) diff --git a/functions/public/Invoke-WPFMicrowin.ps1 b/functions/public/Invoke-WPFMicrowin.ps1 index 23a12fa2..4e729cd8 100644 --- a/functions/public/Invoke-WPFMicrowin.ps1 +++ b/functions/public/Invoke-WPFMicrowin.ps1 @@ -63,11 +63,11 @@ public class PowerManagement { $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)) { + 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 + 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 { @@ -116,7 +116,7 @@ public class PowerManagement { if (Test-Path "$env:TEMP\DRV_EXPORT") { Remove-Item "$env:TEMP\DRV_EXPORT" -Recurse -Force } - if (($injectDrivers -and (Test-Path $sync.MicrowinDriverLocation.Text))) { + if (($injectDrivers -and (Test-Path "$($sync.MicrowinDriverLocation.Text)"))) { Write-Host "Using specified driver source..." dism /english /online /export-driver /destination="$($sync.MicrowinDriverLocation.Text)" | Out-Host if ($?) { @@ -341,7 +341,7 @@ public class PowerManagement { Write-Host "Cleanup complete." Write-Host "Unmounting image..." - Dismount-WindowsImage -Path $scratchDir -Save + Dismount-WindowsImage -Path "$scratchDir" -Save } try { @@ -403,7 +403,7 @@ public class PowerManagement { reg unload HKLM\zSYSTEM Write-Host "Unmounting image..." - Dismount-WindowsImage -Path $scratchDir -Save + Dismount-WindowsImage -Path "$scratchDir" -Save Write-Host "Creating ISO image" @@ -417,7 +417,7 @@ public class PowerManagement { Write-Host "[INFO] Using oscdimg.exe from: $oscdimgPath" - $oscdimgProc = Start-Process -FilePath "$oscdimgPath" -ArgumentList "-m -o -u2 -udfver102 -bootdata:2#p0,e,b$mountDir\boot\etfsboot.com#pEF,e,b$mountDir\efi\microsoft\boot\efisys.bin `"$mountDir`" `"$($SaveDialog.FileName)`"" -Wait -PassThru -NoNewWindow + $oscdimgProc = Start-Process -FilePath "$oscdimgPath" -ArgumentList "-m -o -u2 -udfver102 -bootdata:2#p0,e,b`"$mountDir\boot\etfsboot.com`"#pEF,e,b`"$mountDir\efi\microsoft\boot\efisys.bin`" `"$mountDir`" `"$($SaveDialog.FileName)`"" -Wait -PassThru -NoNewWindow $LASTEXITCODE = $oscdimgProc.ExitCode From 0919e78693fe5ff4dcc10d0a8fe99625bd20b68e Mon Sep 17 00:00:00 2001 From: Psyi Rius <99079175+psyirius@users.noreply.github.com> Date: Mon, 12 Aug 2024 15:10:07 -0700 Subject: [PATCH 2/4] microwin remove expedited apps (#2555) --- functions/public/Invoke-WPFMicrowin.ps1 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/functions/public/Invoke-WPFMicrowin.ps1 b/functions/public/Invoke-WPFMicrowin.ps1 index 4e729cd8..4b69fde6 100644 --- a/functions/public/Invoke-WPFMicrowin.ps1 +++ b/functions/public/Invoke-WPFMicrowin.ps1 @@ -303,6 +303,22 @@ public class PowerManagement { } } + # Prevent Windows Update Installing so called Expedited Apps + @( + 'EdgeUpdate', + 'DevHomeUpdate', + 'OutlookUpdate', + 'CrossDeviceUpdate' + ) | ForEach-Object { + Write-Host "Removing Windows Expedited App: $_" + + # Copied here After Installation (Online) + # reg delete "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Orchestrator\UScheduler\$_" /f | Out-Null + + # When in Offline Image + reg delete "HKLM\zSOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\$_" /f | Out-Null + } + reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Search" /v "SearchboxTaskbarMode" /t REG_DWORD /d 0 /f Write-Host "Setting all services to start manually" reg add "HKLM\zSOFTWARE\CurrentControlSet\Services" /v Start /t REG_DWORD /d 3 /f From 5d7d121e1fa467ff398363403cbdb7f5a247e14c Mon Sep 17 00:00:00 2001 From: MyDrift Date: Tue, 13 Aug 2024 00:10:44 +0200 Subject: [PATCH 3/4] fix get state & add disable emoticon (#2554) --- functions/private/Get-WinUtilToggleStatus.ps1 | 5 +++-- functions/private/Invoke-WinUtilDetailedBSoD.ps1 | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/functions/private/Get-WinUtilToggleStatus.ps1 b/functions/private/Get-WinUtilToggleStatus.ps1 index 019978a4..ea349779 100644 --- a/functions/private/Get-WinUtilToggleStatus.ps1 +++ b/functions/private/Get-WinUtilToggleStatus.ps1 @@ -140,8 +140,9 @@ Function Get-WinUtilToggleStatus { } } if ($ToggleSwitch -eq "WPFToggleDetailedBSoD") { - $DetailedBSoD = (Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl').DisplayParameters - if($DetailedBSoD -eq 0) { + $DetailedBSoD1 = (Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl').DisplayParameters + $DetailedBSoD2 = (Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl').DisableEmoticon + if (($DetailedBSoD1 -eq 0) -or ($DetailedBSoD2 -eq 0) -or !$DetailedBSoD1 -or !$DetailedBSoD2) { return $false } else { return $true diff --git a/functions/private/Invoke-WinUtilDetailedBSoD.ps1 b/functions/private/Invoke-WinUtilDetailedBSoD.ps1 index 21b0a84f..efe4f624 100644 --- a/functions/private/Invoke-WinUtilDetailedBSoD.ps1 +++ b/functions/private/Invoke-WinUtilDetailedBSoD.ps1 @@ -18,6 +18,10 @@ Function Invoke-WinUtilDetailedBSoD { } $Path = "HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl" + $dwords = ("DisplayParameters", "DisableEmoticon") + foreach ($name in $dwords) { + Set-ItemProperty -Path $Path -Name $name -Value $value + } Set-ItemProperty -Path $Path -Name DisplayParameters -Value $value } catch [System.Security.SecurityException] { Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception" From e90156adb91948bc77bcbb4f13bd7d2946839273 Mon Sep 17 00:00:00 2001 From: Psyi Rius <99079175+psyirius@users.noreply.github.com> Date: Mon, 12 Aug 2024 15:12:53 -0700 Subject: [PATCH 4/4] undo dism add-edge (#2553) --- functions/public/Invoke-WPFMicrowin.ps1 | 79 ++++++++++++++++++------- 1 file changed, 56 insertions(+), 23 deletions(-) diff --git a/functions/public/Invoke-WPFMicrowin.ps1 b/functions/public/Invoke-WPFMicrowin.ps1 index 4b69fde6..b0f34ad2 100644 --- a/functions/public/Invoke-WPFMicrowin.ps1 +++ b/functions/public/Invoke-WPFMicrowin.ps1 @@ -174,12 +174,13 @@ public class PowerManagement { Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Program Files\Windows Defender" -Directory Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Program Files (x86)\Windows Defender" } - if (!$keepEdge) { - Write-Host "Removing Edge" - Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Program Files (x86)\Microsoft" -mask "*edge*" -Directory - Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Program Files\Microsoft" -mask "*edge*" -Directory - Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\SystemApps" -mask "*edge*" -Directory - } + # if (!$keepEdge) { + # # this is destructive and might result in touching SystemApps is not recommended unless you going complete rogue on trimming edge and telemetry + # Write-Host "Removing Edge" + # Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Program Files (x86)\Microsoft" -mask "*edge*" -Directory + # Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Program Files\Microsoft" -mask "*edge*" -Directory + # Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\SystemApps" -mask "*edge*" -Directory + # } Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\DiagTrack" -Directory Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\InboxApps" -Directory @@ -283,24 +284,56 @@ public class PowerManagement { reg add "HKLM\zSYSTEM\Setup\MoSetup" /v "AllowUpgradesWithUnsupportedTPMOrCPU" /t REG_DWORD /d 1 /f if (!$keepEdge) { - Write-Host "Removing Edge icon from taskbar" - reg delete "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Taskband" /v "Favorites" /f >$null 2>&1 - reg delete "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Taskband" /v "FavoritesChanges" /f >$null 2>&1 - reg delete "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Taskband" /v "Pinned" /f >$null 2>&1 - reg delete "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Taskband" /v "LayoutCycle" /f >$null 2>&1 - Write-Host "Edge icon removed from taskbar" - if (Test-Path "HKLM:\zSOFTWARE\WOW6432Node") { - # Remove leftovers of 64-bit installations - # --- - # Remove registry values first... - reg delete "HKLM\zSOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge" /va /f > $null 2>&1 - reg delete "HKLM\zSOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge Update" /va /f > $null 2>&1 - reg delete "HKLM\zSOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft EdgeWebView" /va /f > $null 2>&1 - # ...then the registry keys - reg delete "HKLM\zSOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge" /f > $null 2>&1 - reg delete "HKLM\zSOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge Update" /f > $null 2>&1 - reg delete "HKLM\zSOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft EdgeWebView" /f > $null 2>&1 + # Undo changes made by -> Dism Add-Edge Edge.wim (Trust Me: this is the non-destructive way to unintegrate Edge) + + Write-Host "Removing Edge" + + # Microsoft Edge + reg delete "HKLM\zSOFTWARE\Microsoft\Active Setup\Installed Components\{9459C573-B17A-45AE-9F64-1857B5D58CEE}" /f | Out-Null + + reg delete "HKLM\zSOFTWARE\Wow6432Node\Microsoft\EdgeUpdate\Clients\{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" /f | Out-Null + reg delete "HKLM\zSOFTWARE\Wow6432Node\Microsoft\EdgeUpdate\ClientState\{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" /f | Out-Null + + reg delete "HKLM\zSOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge" /f | Out-Null + + if (Test-Path "$scratchDir\Program Files (x86)\Microsoft\Edge" -Type Container) { + Remove-Item "$scratchDir\Program Files (x86)\Microsoft\Edge" -Recurse -Force | Out-Null } + + # Extra + reg delete "HKLM\zSOFTWARE\Microsoft\MicrosoftEdge" /f | Out-Null + + # Microsoft EdgeWebView + reg delete "HKLM\zSOFTWARE\Wow6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" /f | Out-Null + reg delete "HKLM\zSOFTWARE\Wow6432Node\Microsoft\EdgeUpdate\ClientState\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" /f | Out-Null + + reg delete "HKLM\zSOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft EdgeWebView" /f | Out-Null + + if (Test-Path "$scratchDir\Program Files (x86)\Microsoft\EdgeWebView" -Type Container) { + Remove-Item "$scratchDir\Program Files (x86)\Microsoft\EdgeWebView" -Recurse -Force | Out-Null + } + + # Edge Core + if (Test-Path "$scratchDir\Program Files (x86)\Microsoft\EdgeCore" -Type Container) { + Remove-Item "$scratchDir\Program Files (x86)\Microsoft\EdgeCore" -Recurse -Force | Out-Null + } + + # Microsoft Edge Update + reg delete "HKLM\zSOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\MicrosoftEdgeUpdate.exe" /f | Out-Null + + reg delete "HKLM\zSOFTWARE\Wow6432Node\Microsoft\EdgeUpdate" /f | Out-Null + reg delete "HKLM\zSOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge Update" /f | Out-Null + + # Microsoft Edge Update :: Services + reg delete "HKLM\zSYSTEM\ControlSet001\Services\edgeupdate" /f | Out-Null + reg delete "HKLM\zSYSTEM\ControlSet001\Services\edgeupdatem" /f | Out-Null + + if (Test-Path "$scratchDir\Program Files (x86)\Microsoft\EdgeUpdate" -Type Container) { + Remove-Item "$scratchDir\Program Files (x86)\Microsoft\EdgeUpdate" -Recurse -Force | Out-Null + } + + # Prevent EdgeChromium from Installing in the future + reg add "HKLM\zSOFTWARE\Microsoft\EdgeUpdate" /v "DoNotUpdateToEdgeWithChromium" /t REG_DWORD /d "1" /f | Out-Null } # Prevent Windows Update Installing so called Expedited Apps