Skip to content

Commit

Permalink
Test 2023 12 20 (#1337)
Browse files Browse the repository at this point in the history
* Update winutil.ps1

* [Fix]: MicroWin finds but fails to use system oscdimg (#1298)

* Update winutil.ps1 (#1295)

* [Fix]: MicroWin finds but fails to use system oscdimg

* Compiled change b740693

---------

Co-authored-by: Chris Titus <[email protected]>

* Fix wrong hash verification for oscdimg (#1301)

* Update winutil.ps1 (#1295)

* Fixed wrong hash verification for oscdimg

---------

Co-authored-by: Chris Titus <[email protected]>

* Fix Winget package for Chromium and add Ungoogled-Chromium (#1306)

* Fix Chocolatey package for Chromium, add Ungoogled-Chromium

The Chocolatey package for Chromium was previously the one for Ungoogled-Chromium instead, I fixed it and added Ungoogled-Chromium as a separate package instead.

* Add ungoogled-chromium to inputXML

* Making Install section fully data driven (#1326)

Co-authored-by: KonTy <[email protected]>

* Update README for India blocking (#1336)

* Fixed a couple of MicroWin issues (#1313)

* Update winutil.ps1 (#1295)

* Update MicroWin-Helper.ps1

Fix AppX package issue

* Update winutil.ps1

Fixed AppX package removal issue

* Added error detection to AppX removal

Adds error detection to the AppX package removal function in case the process of getting applications fails

This change might fix issue #1324

* Force DISM commands to be in English

Fixes an issue where MicroWin processing would fail on hosts with languages other than English.

This is because, by default, DISM uses the system language. By passing the /English flag, we're forcing DISM to be in English

---------

Co-authored-by: Chris Titus <[email protected]>

* fix app display to be alphabetical

---------

Co-authored-by: kian yamamoto <[email protected]>
Co-authored-by: Júlio C. Oliveira <[email protected]>
Co-authored-by: AlbydS <[email protected]>
Co-authored-by: KonTy <[email protected]>
Co-authored-by: KonTy <[email protected]>
Co-authored-by: Munkk <[email protected]>
Co-authored-by: CodingWonders <[email protected]>
  • Loading branch information
8 people authored Jan 2, 2024
1 parent 3bb4856 commit 771c268
Show file tree
Hide file tree
Showing 9 changed files with 1,958 additions and 1,667 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: <https://timesofindia.indiatimes.com/gadgets-news/github-content-domain-blocked-for-these-indian-users-reports/articleshow/96687992.cms>

Expand Down
Binary file modified config/applications.json
Binary file not shown.
2 changes: 1 addition & 1 deletion functions/private/Get-Oscdimg.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
32 changes: 19 additions & 13 deletions functions/private/MicroWin-Helper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand All @@ -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)
Expand Down
9 changes: 4 additions & 5 deletions functions/public/Invoke-WPFGetIso.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions functions/public/Invoke-WPFMicrowin.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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..."
Expand Down Expand Up @@ -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
{
Expand Down
50 changes: 47 additions & 3 deletions scripts/main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,55 @@ $sync.runspace.Open()

$inputXML = $inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^<Win.*', '<Window'

if ((Get-WinUtilToggleStatus WPFToggleDarkMode) -eq $True){
$organizedData = @{}
# Iterate through JSON data and organize by panel and category
foreach ($appName in $sync.configs.applications.PSObject.Properties.Name) {
$appInfo = $sync.configs.applications.$appName

# Create an object for the application
$appObject = [PSCustomObject]@{
Name = $appName
Category = $appInfo.Category
Content = $appInfo.Content
Choco = $appInfo.choco
Winget = $appInfo.winget
Panel = $appInfo.panel
}

if (-not $organizedData.ContainsKey($appInfo.panel)) {
$organizedData[$appInfo.panel] = @{}
}

if (-not $organizedData[$appInfo.panel].ContainsKey($appInfo.Category)) {
$organizedData[$appInfo.panel][$appInfo.Category] = @{}
}

# Store application data in a sub-array under the category
$organizedData[$appInfo.panel][$appInfo.Category][$appName] = $appObject
}

# Iterate through organizedData by panel, category, and application
foreach ($panel in $organizedData.Keys) {
foreach ($category in $organizedData[$panel].Keys) {
$blockXml += "<Label Content=""$($category)"" FontSize=""16""/>`n"
$sortedApps = $organizedData[$panel][$category].Keys | Sort-Object
foreach ($appName in $sortedApps) {
$appInfo = $organizedData[$panel][$category][$appName]

$blockXml += "<CheckBox Name=""$appName"" Content=""$($appInfo.Content)""/>`n"
}
}

$inputXML = $inputXML -replace "{{InstallPanel$panel}}", $blockXml
$blockXml = ""
}

if ((Get-WinUtilToggleStatus WPFToggleDarkMode) -eq $True) {
$ctttheme = 'Matrix'
}
Else{
else {
$ctttheme = 'Classic'
}

$inputXML = Set-WinUtilUITheme -inputXML $inputXML -themeName $ctttheme

[void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
Expand All @@ -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
#===========================================================================
Expand Down
Loading

0 comments on commit 771c268

Please sign in to comment.