diff --git a/README.md b/README.md index 260c7f2b..95bf4738 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Courtesy of the issue raised at: [#144](/../../issues/144) ### Issues: -- If you are unable to resolve christitus.com/win and are getting errors launching the tool, it might be due to India blocking GitHub's content domain and preventing downloads. You'll be required to use a VPN to tunnel out of India. +- If you are unable to resolve christitus.com/win and are getting errors launching the tool, it might be due to India blocking GitHub's content domain and preventing downloads. You may use a VPN or change your DNS provider to Google/Cloudflare/etc. Source: diff --git a/config/applications.json b/config/applications.json index 1d23aeb6..52edb8f1 100755 Binary files a/config/applications.json and b/config/applications.json differ diff --git a/functions/private/Get-Oscdimg.ps1 b/functions/private/Get-Oscdimg.ps1 index 41116dea..47736500 100644 --- a/functions/private/Get-Oscdimg.ps1 +++ b/functions/private/Get-Oscdimg.ps1 @@ -18,7 +18,7 @@ function Get-Oscdimg { Write-Host "[INFO] oscdimg.exe SHA-256 Hash: $sha256Hash" - $expectedHash = "F62B91A06F94019A878DD9D1713FFBA2140B863C131EB78A329B4CCD6102960E" # Replace with the actual expected hash + $expectedHash = "AB9E161049D293B544961BFDF2D61244ADE79376D6423DF4F60BF9B147D3C78D" # Replace with the actual expected hash if ($sha256Hash -eq $expectedHash) { Write-Host "Hashes match. File is verified." } else { diff --git a/functions/private/MicroWin-Helper.ps1 b/functions/private/MicroWin-Helper.ps1 index b4c4160b..0291e7e8 100644 --- a/functions/private/MicroWin-Helper.ps1 +++ b/functions/private/MicroWin-Helper.ps1 @@ -12,7 +12,7 @@ function Remove-Features([switch] $dumpFeatures = $false, [switch] $keepDefender Remove-Features -keepDefender:$false #> - $appxlist = dism /image:$scratchDir /Get-Features | Select-String -Pattern "Feature Name : " -CaseSensitive -SimpleMatch + $appxlist = dism /English /image:$scratchDir /Get-Features | Select-String -Pattern "Feature Name : " -CaseSensitive -SimpleMatch $appxlist = $appxlist -split "Feature Name : " | Where-Object {$_} if ($dumpFeatures) { @@ -40,7 +40,7 @@ function Remove-Features([switch] $dumpFeatures = $false, [switch] $keepDefender function Remove-Packages { - $appxlist = dism /Image:$scratchDir /Get-Packages | Select-String -Pattern "Package Identity : " -CaseSensitive -SimpleMatch + $appxlist = dism /English /Image:$scratchDir /Get-Packages | Select-String -Pattern "Package Identity : " -CaseSensitive -SimpleMatch $appxlist = $appxlist -split "Package Identity : " | Where-Object {$_} $appxlist = $appxlist | Where-Object { @@ -85,7 +85,7 @@ function Remove-Packages { $status = "Removing $appx" Write-Progress -Activity "Removing Apps" -Status $status -PercentComplete ($counter++/$appxlist.Count*100) - dism /image:$scratchDir /Remove-Package /PackageName:$appx /NoRestart + dism /English /image:$scratchDir /Remove-Package /PackageName:$appx /NoRestart } Write-Progress -Activity "Removing Apps" -Status "Ready" -Completed } @@ -104,16 +104,22 @@ function Remove-ProvisionedPackages $_.PackageName -NotLike "*Wifi*" -and $_.PackageName -NotLike "*Foundation*" } - - $counter = 0 - foreach ($appx in $appxProvisionedPackages) - { - $status = "Removing Provisioned $appx" - Write-Progress -Activity "Removing Provisioned Apps" -Status $status -PercentComplete ($counter++/$appxProvisionedPackages.Count*100) - dism /image:$scratchDir /Remove-ProvisionedAppxPackage /PackageName:$appx /NoRestart - - } - Write-Progress -Activity "Removing Provisioned Apps" -Status "Ready" -Completed + + if ($?) + { + $counter = 0 + foreach ($appx in $appxProvisionedPackages) + { + $status = "Removing Provisioned $($appx.PackageName)" + Write-Progress -Activity "Removing Provisioned Apps" -Status $status -PercentComplete ($counter++/$appxProvisionedPackages.Count*100) + dism /English /image:$scratchDir /Remove-ProvisionedAppxPackage /PackageName:$($appx.PackageName) /NoRestart + } + Write-Progress -Activity "Removing Provisioned Apps" -Status "Ready" -Completed + } + else + { + Write-Host "Could not get Provisioned App information. Skipping process..." + } } function Copy-ToUSB([string] $fileToCopy) diff --git a/functions/public/Invoke-WPFGetIso.ps1 b/functions/public/Invoke-WPFGetIso.ps1 index b9bfd174..8c819a2e 100644 --- a/functions/public/Invoke-WPFGetIso.ps1 +++ b/functions/public/Invoke-WPFGetIso.ps1 @@ -18,12 +18,10 @@ function Invoke-WPFGetIso { Write-Host "/ /\/\ \| || (__ | | | (_) | \ /\ / | || | | | " Write-Host "\/ \/|_| \___||_| \___/ \/ \/ |_||_| |_| " - $oscdImgFound = [bool] (Get-Command -ErrorAction Ignore -Type Application oscdimg.exe) + $oscdimgPath = Join-Path $env:TEMP 'oscdimg.exe' + $oscdImgFound = [bool] (Get-Command -ErrorAction Ignore -Type Application oscdimg.exe) -or (Test-Path $oscdimgPath -PathType Leaf) Write-Host "oscdimg.exe on system: $oscdImgFound" - $oscdimgPath = Join-Path $env:TEMP 'oscdimg.exe' - $oscdImgFound = Test-Path $oscdimgPath -PathType Leaf - if (!$oscdImgFound) { $downloadFromGitHub = $sync.WPFMicrowinDownloadFromGitHub.IsChecked @@ -32,7 +30,7 @@ function Invoke-WPFGetIso { { # only show the message to people who did check the box to download from github, if you check the box # you consent to downloading it, no need to show extra dialogs - [System.Windows.MessageBox]::Show("oscdimge.exe is not found on the system, winutil will now attempt do download and install it using choco or github. This might take a long time.") + [System.Windows.MessageBox]::Show("oscdimge.exe is not found on the system, winutil will now attempt do download and install it using choco. This might take a long time.") # the step below needs choco to download oscdimg $chocoFound = [bool] (Get-Command -ErrorAction Ignore -Type Application choco) Write-Host "choco on system: $chocoFound" @@ -47,6 +45,7 @@ function Invoke-WPFGetIso { return } else { + [System.Windows.MessageBox]::Show("oscdimge.exe is not found on the system, winutil will now attempt do download and install it from github. This might take a long time.") Get-Oscdimg -oscdimgPath $oscdimgPath $oscdImgFound = Test-Path $oscdimgPath -PathType Leaf if (!$oscdImgFound) { diff --git a/functions/public/Invoke-WPFMicrowin.ps1 b/functions/public/Invoke-WPFMicrowin.ps1 index ca27b8ef..0b50c9eb 100644 --- a/functions/public/Invoke-WPFMicrowin.ps1 +++ b/functions/public/Invoke-WPFMicrowin.ps1 @@ -44,7 +44,7 @@ function Invoke-WPFMicrowin { if (Test-Path $driverPath) { Write-Host "Adding Windows Drivers image($scratchDir) drivers($driverPath) " - dism /image:$scratchDir /add-driver /driver:$driverPath /recurse | Out-Host + dism /English /image:$scratchDir /add-driver /driver:$driverPath /recurse | Out-Host } else { @@ -136,7 +136,7 @@ function Invoke-WPFMicrowin { Write-Host "Copy link to winutil.ps1 into the ISO" $desktopDir = "$($scratchDir)\Windows\Users\Default\Desktop" New-Item -ItemType Directory -Force -Path "$desktopDir" - dism /image:$($scratchDir) /set-profilepath:"$($scratchDir)\Windows\Users\Default" + dism /English /image:$($scratchDir) /set-profilepath:"$($scratchDir)\Windows\Users\Default" $command = "powershell.exe -NoProfile -ExecutionPolicy Bypass -Command 'irm https://christitus.com/win | iex'" $shortcutPath = "$desktopDir\WinUtil.lnk" $shell = New-Object -ComObject WScript.Shell @@ -238,7 +238,7 @@ function Invoke-WPFMicrowin { reg unload HKLM\zSYSTEM Write-Host "Cleaning up image..." - dism /image:$scratchDir /Cleanup-Image /StartComponentCleanup /ResetBase + dism /English /image:$scratchDir /Cleanup-Image /StartComponentCleanup /ResetBase Write-Host "Cleanup complete." Write-Host "Unmounting image..." @@ -270,7 +270,7 @@ function Invoke-WPFMicrowin { if (Test-Path $driverPath) { Write-Host "Adding Windows Drivers image($scratchDir) drivers($driverPath) " - dism /image:$scratchDir /add-driver /driver:$driverPath /recurse | Out-Host + dism /English /image:$scratchDir /add-driver /driver:$driverPath /recurse | Out-Host } else { diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 2e716be1..b7e88011 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -53,13 +53,55 @@ $sync.runspace.Open() $inputXML = $inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^`n" + $sortedApps = $organizedData[$panel][$category].Keys | Sort-Object + foreach ($appName in $sortedApps) { + $appInfo = $organizedData[$panel][$category][$appName] + + $blockXml += "`n" + } + } + + $inputXML = $inputXML -replace "{{InstallPanel$panel}}", $blockXml + $blockXml = "" +} + +if ((Get-WinUtilToggleStatus WPFToggleDarkMode) -eq $True) { + $ctttheme = 'Matrix' +} +else { + $ctttheme = 'Classic' +} $inputXML = Set-WinUtilUITheme -inputXML $inputXML -themeName $ctttheme [void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework') @@ -79,6 +121,8 @@ catch { Write-Host "Unable to load Windows.Markup.XamlReader. Double-check syntax and ensure .net is installed." } + + #=========================================================================== # Store Form Objects In PowerShell #=========================================================================== diff --git a/winutil.ps1 b/winutil.ps1 index 56b17983..e81ce133 100644 --- a/winutil.ps1 +++ b/winutil.ps1 @@ -10,7 +10,7 @@ Author : Chris Titus @christitustech Runspace Author: @DeveloperDurp GitHub : https://github.com/ChrisTitusTech - Version : 23.12.19 + Version : 24.01.02 #> Start-Transcript $ENV:TEMP\Winutil.log -Append @@ -22,7 +22,7 @@ Add-Type -AssemblyName System.Windows.Forms # Variable to sync between runspaces $sync = [Hashtable]::Synchronized(@{}) $sync.PSScriptRoot = $PSScriptRoot -$sync.version = "23.12.19" +$sync.version = "24.01.02" $sync.configs = @{} $sync.ProcessRunning = $false @@ -190,7 +190,7 @@ function Get-Oscdimg { Write-Host "[INFO] oscdimg.exe SHA-256 Hash: $sha256Hash" - $expectedHash = "F62B91A06F94019A878DD9D1713FFBA2140B863C131EB78A329B4CCD6102960E" # Replace with the actual expected hash + $expectedHash = "AB9E161049D293B544961BFDF2D61244ADE79376D6423DF4F60BF9B147D3C78D" # Replace with the actual expected hash if ($sha256Hash -eq $expectedHash) { Write-Host "Hashes match. File is verified." } else { @@ -1043,7 +1043,7 @@ function Remove-Features([switch] $dumpFeatures = $false, [switch] $keepDefender Remove-Features -keepDefender:$false #> - $appxlist = dism /image:$scratchDir /Get-Features | Select-String -Pattern "Feature Name : " -CaseSensitive -SimpleMatch + $appxlist = dism /English /image:$scratchDir /Get-Features | Select-String -Pattern "Feature Name : " -CaseSensitive -SimpleMatch $appxlist = $appxlist -split "Feature Name : " | Where-Object {$_} if ($dumpFeatures) { @@ -1071,7 +1071,7 @@ function Remove-Features([switch] $dumpFeatures = $false, [switch] $keepDefender function Remove-Packages { - $appxlist = dism /Image:$scratchDir /Get-Packages | Select-String -Pattern "Package Identity : " -CaseSensitive -SimpleMatch + $appxlist = dism /English /Image:$scratchDir /Get-Packages | Select-String -Pattern "Package Identity : " -CaseSensitive -SimpleMatch $appxlist = $appxlist -split "Package Identity : " | Where-Object {$_} $appxlist = $appxlist | Where-Object { @@ -1116,7 +1116,7 @@ function Remove-Packages { $status = "Removing $appx" Write-Progress -Activity "Removing Apps" -Status $status -PercentComplete ($counter++/$appxlist.Count*100) - dism /image:$scratchDir /Remove-Package /PackageName:$appx /NoRestart + dism /English /image:$scratchDir /Remove-Package /PackageName:$appx /NoRestart } Write-Progress -Activity "Removing Apps" -Status "Ready" -Completed } @@ -1135,16 +1135,22 @@ function Remove-ProvisionedPackages $_.PackageName -NotLike "*Wifi*" -and $_.PackageName -NotLike "*Foundation*" } - - $counter = 0 - foreach ($appx in $appxProvisionedPackages) - { - $status = "Removing Provisioned $appx" - Write-Progress -Activity "Removing Provisioned Apps" -Status $status -PercentComplete ($counter++/$appxProvisionedPackages.Count*100) - dism /image:$scratchDir /Remove-ProvisionedAppxPackage /PackageName:$appx /NoRestart - - } - Write-Progress -Activity "Removing Provisioned Apps" -Status "Ready" -Completed + + if ($?) + { + $counter = 0 + foreach ($appx in $appxProvisionedPackages) + { + $status = "Removing Provisioned $($appx.PackageName)" + Write-Progress -Activity "Removing Provisioned Apps" -Status $status -PercentComplete ($counter++/$appxProvisionedPackages.Count*100) + dism /English /image:$scratchDir /Remove-ProvisionedAppxPackage /PackageName:$($appx.PackageName) /NoRestart + } + Write-Progress -Activity "Removing Provisioned Apps" -Status "Ready" -Completed + } + else + { + Write-Host "Could not get Provisioned App information. Skipping process..." + } } function Copy-ToUSB([string] $fileToCopy) @@ -2313,12 +2319,10 @@ function Invoke-WPFGetIso { Write-Host "/ /\/\ \| || (__ | | | (_) | \ /\ / | || | | | " Write-Host "\/ \/|_| \___||_| \___/ \/ \/ |_||_| |_| " - $oscdImgFound = [bool] (Get-Command -ErrorAction Ignore -Type Application oscdimg.exe) + $oscdimgPath = Join-Path $env:TEMP 'oscdimg.exe' + $oscdImgFound = [bool] (Get-Command -ErrorAction Ignore -Type Application oscdimg.exe) -or (Test-Path $oscdimgPath -PathType Leaf) Write-Host "oscdimg.exe on system: $oscdImgFound" - $oscdimgPath = Join-Path $env:TEMP 'oscdimg.exe' - $oscdImgFound = Test-Path $oscdimgPath -PathType Leaf - if (!$oscdImgFound) { $downloadFromGitHub = $sync.WPFMicrowinDownloadFromGitHub.IsChecked @@ -2327,7 +2331,7 @@ function Invoke-WPFGetIso { { # only show the message to people who did check the box to download from github, if you check the box # you consent to downloading it, no need to show extra dialogs - [System.Windows.MessageBox]::Show("oscdimge.exe is not found on the system, winutil will now attempt do download and install it using choco or github. This might take a long time.") + [System.Windows.MessageBox]::Show("oscdimge.exe is not found on the system, winutil will now attempt do download and install it using choco. This might take a long time.") # the step below needs choco to download oscdimg $chocoFound = [bool] (Get-Command -ErrorAction Ignore -Type Application choco) Write-Host "choco on system: $chocoFound" @@ -2342,6 +2346,7 @@ function Invoke-WPFGetIso { return } else { + [System.Windows.MessageBox]::Show("oscdimge.exe is not found on the system, winutil will now attempt do download and install it from github. This might take a long time.") Get-Oscdimg -oscdimgPath $oscdimgPath $oscdImgFound = Test-Path $oscdimgPath -PathType Leaf if (!$oscdImgFound) { @@ -2616,7 +2621,7 @@ function Invoke-WPFMicrowin { if (Test-Path $driverPath) { Write-Host "Adding Windows Drivers image($scratchDir) drivers($driverPath) " - dism /image:$scratchDir /add-driver /driver:$driverPath /recurse | Out-Host + dism /English /image:$scratchDir /add-driver /driver:$driverPath /recurse | Out-Host } else { @@ -2708,7 +2713,7 @@ function Invoke-WPFMicrowin { Write-Host "Copy link to winutil.ps1 into the ISO" $desktopDir = "$($scratchDir)\Windows\Users\Default\Desktop" New-Item -ItemType Directory -Force -Path "$desktopDir" - dism /image:$($scratchDir) /set-profilepath:"$($scratchDir)\Windows\Users\Default" + dism /English /image:$($scratchDir) /set-profilepath:"$($scratchDir)\Windows\Users\Default" $command = "powershell.exe -NoProfile -ExecutionPolicy Bypass -Command 'irm https://christitus.com/win | iex'" $shortcutPath = "$desktopDir\WinUtil.lnk" $shell = New-Object -ComObject WScript.Shell @@ -2810,7 +2815,7 @@ function Invoke-WPFMicrowin { reg unload HKLM\zSYSTEM Write-Host "Cleaning up image..." - dism /image:$scratchDir /Cleanup-Image /StartComponentCleanup /ResetBase + dism /English /image:$scratchDir /Cleanup-Image /StartComponentCleanup /ResetBase Write-Host "Cleanup complete." Write-Host "Unmounting image..." @@ -2842,7 +2847,7 @@ function Invoke-WPFMicrowin { if (Test-Path $driverPath) { Write-Host "Adding Windows Drivers image($scratchDir) drivers($driverPath) " - dism /image:$scratchDir /add-driver /driver:$driverPath /recurse | Out-Host + dism /English /image:$scratchDir /add-driver /driver:$driverPath /recurse | Out-Host } else { @@ -4265,320 +4270,66 @@ $inputXML = ' - - + + - - - - - - - - + + - - + + - +