Compare commits

..

2 Commits

Author SHA1 Message Date
1404efab26 [MicroWin] First Anniversary Special PR (#2853)
* Fix minor denomination problem for packages

* Fix incorrect filter of OS packages

Packages such as the metadata for capabilities (FoDs) or the foundation package were being incorrectly filtered. They were part of `Remove-ProvisionedPackages`, which only removes AppX packages. These are **OS packages**, something completely different

* Fixed indentation

* Exclude `Microsoft-RemoteDesktopConnection`

Exclude that from feature list. Fixes #2705

* Remove DISM from AppX removal listings

DISM is a system component. It will never be an AppX package. This is unnecessary

* Improve error handling for file copy

* Remove space (for some reason)

Compilation script is very adamant that this should be this way

* Exclude the VBSCRIPT Features on Demand from pkgs

Exclude the VBSCRIPT feature on demand (or capability) from package removal. Some people were reporting that excluding VBSCRIPT fixed problems with AMD chipset drivers on MicroWin

* Exclude Recall from feature listings

This fixes problems people were experiencing where the file explorer would go back to the Windows 10 layout

* Improve error output

* Add 24H2 to release list

* Detect Windows 10 and show compatibility dialog

* Disable some insane desktop stuff on Windows 10

I've only been able to disable Search Highlights. News and Interests persists

* Change policy for News and Interests

Avoid showing "Access denied" errors for this. This is still broken - News and Interests is still there. [louder]Linus Torvalds curse word here[/louder]

Anyway, if someone wants to give setting this up a shot, send me suggestions on how to do this

* Write suggestion for AV

* Hold errored packages in a list

Items are being added correctly, but I can't get that to show to the end-user. Perhaps a different approach will work

* Remove older Windows versions from download list

Sadly, the links for these had been removed by Microsoft, in favor of the latest version (24H2)

* Add sorting to error messages

Thanks @og-mrk for the suggestion and the patch (even though I applied it myself)

* Make error messages easier to view (#1)

* Make error messages easier to view

* Improve error output

---------

Co-authored-by: CodingWonders <101426328+CodingWonders@users.noreply.github.com>

* Disable Recall on first run

Keeps the Explorer look of modern Windows 11 builds whilst removing the Recall feature (which I think will manifest itself on PCs with Lunar Lake processors)

* Replace "C:\" with environment variable

This still works on single-boot configurations, but presents a more dynamic approach

* Fix Volume Mixer issues and removal of leftovers

Fix originally from @MyDrift-user on #2856

* Add missing piece to last commit

* Default to downloading OSCDIMG from GitHub repo

Chocolatey may not be the way to help us detect the presence of OSCDIMG.

Everyone, unless someone REALLY uses old deployment technology, has moved to Windows ADK 10.0

* Fix Sorting of Errored Packages by using 'Sort-Object' instead of 'IComparer' approach (#2)

Fixes startup issues in PWSH 7

* Remove reference to News and Interests from output

Even though the logic is still there, it doesn't work. I don't want to deal with that anymore. Search Highlights, on the other hand, is removed very easily

* Exclude License packages from removal

They throw an "Access denied" error when trying to remove them. This is a timesaver

---------

Co-authored-by: Mr.k <mineshtine28546271@gmail.com>
2024-10-07 15:37:47 -05:00
1deb863f40 Deploying to main from @ ChrisTitusTech/winutil@de73efa868 🚀 2024-10-07 15:33:02 +00:00
10 changed files with 255 additions and 294 deletions

File diff suppressed because one or more lines are too long

View File

@ -2,12 +2,12 @@
"shared":{ "shared":{
"CustomDialogFontSize": "12", "CustomDialogFontSize": "12",
"CustomDialogFontSizeHeader": "14", "CustomDialogFontSizeHeader": "14",
"CustomDialogLogoSize": "25", "CustomDialogIconSize": "25",
"CustomDialogWidth": "400", "CustomDialogWidth": "400",
"CustomDialogHeight": "200", "CustomDialogHeight": "200",
"FontSize": "12", "FontSize": "12",
"FontFamily": "Arial", "FontFamily": "Arial",
"HeadingFontSize": "16", "FontSizeHeading": "16",
"HeaderFontFamily": "Consolas, Monaco", "HeaderFontFamily": "Consolas, Monaco",
"CheckBoxBulletDecoratorSize": "14", "CheckBoxBulletDecoratorSize": "14",
"CheckBoxMargin": "15,0,0,2", "CheckBoxMargin": "15,0,0,2",
@ -27,7 +27,7 @@
"ButtonFontFamily": "Arial", "ButtonFontFamily": "Arial",
"ButtonWidth": "200", "ButtonWidth": "200",
"ButtonHeight": "25", "ButtonHeight": "25",
"ConfigUpdateButtonFontSize": "14", "ConfigTabButtonFontSize": "16",
"SearchBarWidth": "200", "SearchBarWidth": "200",
"SearchBarHeight": "26", "SearchBarHeight": "26",
"SearchBarTextBoxFontSize": "12", "SearchBarTextBoxFontSize": "12",
@ -44,7 +44,7 @@
"MainForegroundColor": "#232629", "MainForegroundColor": "#232629",
"MainBackgroundColor": "#F7F7F7", "MainBackgroundColor": "#F7F7F7",
"LabelBackgroundColor": "#F7F7F7", "LabelBackgroundColor": "#F7F7F7",
"LinkForegroundColor": "#484848", "LinkForegroundColor": "#232629",
"LinkHoverForegroundColor": "#232629", "LinkHoverForegroundColor": "#232629",
"ScrollBarBackgroundColor": "#4A4D52", "ScrollBarBackgroundColor": "#4A4D52",
"ScrollBarHoverColor": "#5A5D62", "ScrollBarHoverColor": "#5A5D62",

View File

@ -19,10 +19,10 @@ function Copy-Files {
try { try {
$files = Get-ChildItem -Path $path -Recurse:$recurse $files = Get-ChildItem -Path $path -Recurse:$recurse
Write-Host "Copy $($files.Count)(s) from $path to $destination" Write-Host "Copy $($files.Count) file(s) from $path to $destination"
foreach ($file in $files) { foreach ($file in $files) {
$status = "Copy files {0} on {1}: {2}" -f $counter, $files.Count, $file.Name $status = "Copying file {0} of {1}: {2}" -f $counter, $files.Count, $file.Name
Write-Progress -Activity "Copy Windows files" -Status $status -PercentComplete ($counter++/$files.count*100) Write-Progress -Activity "Copy Windows files" -Status $status -PercentComplete ($counter++/$files.count*100)
$restpath = $file.FullName -Replace $path, '' $restpath = $file.FullName -Replace $path, ''
@ -37,7 +37,11 @@ function Copy-Files {
} }
Write-Progress -Activity "Copy Windows files" -Status "Ready" -Completed Write-Progress -Activity "Copy Windows files" -Status "Ready" -Completed
} catch { } catch {
Write-Warning "Unable to Copy all the files due to unhandled exception" Write-Host "Unable to Copy all the files due to an unhandled exception" -ForegroundColor Yellow
Write-Warning $psitem.Exception.StackTrace Write-Host "Error information: $($_.Exception.Message)`n" -ForegroundColor Yellow
Write-Host "Additional information:" -ForegroundColor Yellow
Write-Host $PSItem.Exception.StackTrace
# Write possible suggestions
Write-Host "`nIf you are using an antivirus, try configuring exclusions"
} }
} }

View File

@ -25,6 +25,17 @@ function Test-CompatibleImage() {
} }
} }
class ErroredPackage {
[string]$PackageName
[string]$ErrorMessage
ErroredPackage() { $this.Init(@{} )}
# Constructor for packages that have errored out
ErroredPackage([string]$pkgName, [string]$reason) {
$this.PackageName = $pkgName
$this.ErrorMessage = $reason
}
}
function Get-FidoLangFromCulture { function Get-FidoLangFromCulture {
param ( param (
@ -98,6 +109,8 @@ function Remove-Features() {
$_.FeatureName -NotLike "*Media*" -AND $_.FeatureName -NotLike "*Media*" -AND
$_.FeatureName -NotLike "*NFS*" -AND $_.FeatureName -NotLike "*NFS*" -AND
$_.FeatureName -NotLike "*SearchEngine*" -AND $_.FeatureName -NotLike "*SearchEngine*" -AND
$_.FeatureName -NotLike "*RemoteDesktop*" -AND
$_.FeatureName -NotLike "*Recall*" -AND
$_.State -ne "Disabled" $_.State -ne "Disabled"
} }
@ -157,27 +170,54 @@ function Remove-Packages {
$_ -NotLike "*WMIC*" -AND $_ -NotLike "*WMIC*" -AND
$_ -NotLike "*UI.XaML*" -AND $_ -NotLike "*UI.XaML*" -AND
$_ -NotLike "*Ethernet*" -AND $_ -NotLike "*Ethernet*" -AND
$_ -NotLike "*Wifi*" $_ -NotLike "*Wifi*" -AND
$_ -NotLike "*FodMetadata*" -AND
$_ -NotLike "*Foundation*" -AND
$_ -NotLike "*LanguageFeatures*" -AND
$_ -NotLike "*VBSCRIPT*" -AND
$_ -NotLike "*License*"
} }
$failedCount = 0 $failedCount = 0
$erroredPackages = [System.Collections.Generic.List[ErroredPackage]]::new()
foreach ($pkg in $pkglist) { foreach ($pkg in $pkglist) {
try { try {
$status = "Removing $pkg" $status = "Removing $pkg"
Write-Progress -Activity "Removing Apps" -Status $status -PercentComplete ($counter++/$pkglist.Count*100) Write-Progress -Activity "Removing Packages" -Status $status -PercentComplete ($counter++/$pkglist.Count*100)
Remove-WindowsPackage -Path "$scratchDir" -PackageName $pkg -NoRestart -ErrorAction SilentlyContinue Remove-WindowsPackage -Path "$scratchDir" -PackageName $pkg -NoRestart -ErrorAction SilentlyContinue
} catch { } catch {
# This can happen if the package that is being removed is a permanent one, like FodMetadata # This can happen if the package that is being removed is a permanent one
Write-Host "Could not remove OS package $($pkg)" $erroredPackages.Add([ErroredPackage]::new($pkg, $_.Exception.Message))
$failedCount += 1 $failedCount += 1
continue continue
} }
} }
Write-Progress -Activity "Removing Apps" -Status "Ready" -Completed Write-Progress -Activity "Removing Packages" -Status "Ready" -Completed
if ($failedCount -gt 0) if ($failedCount -gt 0)
{ {
Write-Host "Some packages could not be removed. Do not worry: your image will still work fine. This can happen if the package is permanent or has been superseded by a newer one." Write-Host "$failedCount package(s) could not be removed. Your image will still work fine, however. Below is information on what packages failed to be removed and why."
if ($erroredPackages.Count -gt 0)
{
$erroredPackages = $erroredPackages | Sort-Object -Property ErrorMessage
$previousErroredPackage = $erroredPackages[0]
$counter = 0
Write-Host ""
Write-Host "- $($previousErroredPackage.ErrorMessage)"
foreach ($erroredPackage in $erroredPackages) {
if ($erroredPackage.ErrorMessage -ne $previousErroredPackage.ErrorMessage) {
Write-Host ""
$counter = 0
Write-Host "- $($erroredPackage.ErrorMessage)"
}
$counter += 1
Write-Host " $counter) $($erroredPackage.PackageName)"
$previousErroredPackage = $erroredPackage
}
Write-Host ""
}
} }
} catch { } catch {
Write-Host "Unable to get information about the packages. MicroWin processing will continue, but packages will not be processed" Write-Host "Unable to get information about the packages. MicroWin processing will continue, but packages will not be processed"
@ -201,13 +241,8 @@ function Remove-ProvisionedPackages() {
$appxProvisionedPackages = Get-AppxProvisionedPackage -Path "$($scratchDir)" | Where-Object { $appxProvisionedPackages = Get-AppxProvisionedPackage -Path "$($scratchDir)" | Where-Object {
$_.PackageName -NotLike "*AppInstaller*" -AND $_.PackageName -NotLike "*AppInstaller*" -AND
$_.PackageName -NotLike "*Store*" -and $_.PackageName -NotLike "*Store*" -and
$_.PackageName -NotLike "*dism*" -and
$_.PackageName -NotLike "*Foundation*" -and
$_.PackageName -NotLike "*FodMetadata*" -and
$_.PackageName -NotLike "*LanguageFeatures*" -and
$_.PackageName -NotLike "*Notepad*" -and $_.PackageName -NotLike "*Notepad*" -and
$_.PackageName -NotLike "*Printing*" -and $_.PackageName -NotLike "*Printing*" -and
$_.PackageName -NotLike "*Foundation*" -and
$_.PackageName -NotLike "*YourPhone*" -and $_.PackageName -NotLike "*YourPhone*" -and
$_.PackageName -NotLike "*Xbox*" -and $_.PackageName -NotLike "*Xbox*" -and
$_.PackageName -NotLike "*WindowsTerminal*" -and $_.PackageName -NotLike "*WindowsTerminal*" -and
@ -625,70 +660,70 @@ function New-CheckInstall {
# using here string to embedd firstrun # using here string to embedd firstrun
$checkInstall = @' $checkInstall = @'
@echo off @echo off
if exist "C:\windows\cpu.txt" ( if exist "%HOMEDRIVE%\windows\cpu.txt" (
echo C:\windows\cpu.txt exists echo %HOMEDRIVE%\windows\cpu.txt exists
) else ( ) else (
echo C:\windows\cpu.txt does not exist echo %HOMEDRIVE%\windows\cpu.txt does not exist
) )
if exist "C:\windows\SerialNumber.txt" ( if exist "%HOMEDRIVE%\windows\SerialNumber.txt" (
echo C:\windows\SerialNumber.txt exists echo %HOMEDRIVE%\windows\SerialNumber.txt exists
) else ( ) else (
echo C:\windows\SerialNumber.txt does not exist echo %HOMEDRIVE%\windows\SerialNumber.txt does not exist
) )
if exist "C:\unattend.xml" ( if exist "%HOMEDRIVE%\unattend.xml" (
echo C:\unattend.xml exists echo %HOMEDRIVE%\unattend.xml exists
) else ( ) else (
echo C:\unattend.xml does not exist echo %HOMEDRIVE%\unattend.xml does not exist
) )
if exist "C:\Windows\Setup\Scripts\SetupComplete.cmd" ( if exist "%HOMEDRIVE%\Windows\Setup\Scripts\SetupComplete.cmd" (
echo C:\Windows\Setup\Scripts\SetupComplete.cmd exists echo %HOMEDRIVE%\Windows\Setup\Scripts\SetupComplete.cmd exists
) else ( ) else (
echo C:\Windows\Setup\Scripts\SetupComplete.cmd does not exist echo %HOMEDRIVE%\Windows\Setup\Scripts\SetupComplete.cmd does not exist
) )
if exist "C:\Windows\Panther\unattend.xml" ( if exist "%HOMEDRIVE%\Windows\Panther\unattend.xml" (
echo C:\Windows\Panther\unattend.xml exists echo %HOMEDRIVE%\Windows\Panther\unattend.xml exists
) else ( ) else (
echo C:\Windows\Panther\unattend.xml does not exist echo %HOMEDRIVE%\Windows\Panther\unattend.xml does not exist
) )
if exist "C:\Windows\System32\Sysprep\unattend.xml" ( if exist "%HOMEDRIVE%\Windows\System32\Sysprep\unattend.xml" (
echo C:\Windows\System32\Sysprep\unattend.xml exists echo %HOMEDRIVE%\Windows\System32\Sysprep\unattend.xml exists
) else ( ) else (
echo C:\Windows\System32\Sysprep\unattend.xml does not exist echo %HOMEDRIVE%\Windows\System32\Sysprep\unattend.xml does not exist
) )
if exist "C:\Windows\FirstStartup.ps1" ( if exist "%HOMEDRIVE%\Windows\FirstStartup.ps1" (
echo C:\Windows\FirstStartup.ps1 exists echo %HOMEDRIVE%\Windows\FirstStartup.ps1 exists
) else ( ) else (
echo C:\Windows\FirstStartup.ps1 does not exist echo %HOMEDRIVE%\Windows\FirstStartup.ps1 does not exist
) )
if exist "C:\Windows\winutil.ps1" ( if exist "%HOMEDRIVE%\Windows\winutil.ps1" (
echo C:\Windows\winutil.ps1 exists echo %HOMEDRIVE%\Windows\winutil.ps1 exists
) else ( ) else (
echo C:\Windows\winutil.ps1 does not exist echo %HOMEDRIVE%\Windows\winutil.ps1 does not exist
) )
if exist "C:\Windows\LogSpecialize.txt" ( if exist "%HOMEDRIVE%\Windows\LogSpecialize.txt" (
echo C:\Windows\LogSpecialize.txt exists echo %HOMEDRIVE%\Windows\LogSpecialize.txt exists
) else ( ) else (
echo C:\Windows\LogSpecialize.txt does not exist echo %HOMEDRIVE%\Windows\LogSpecialize.txt does not exist
) )
if exist "C:\Windows\LogAuditUser.txt" ( if exist "%HOMEDRIVE%\Windows\LogAuditUser.txt" (
echo C:\Windows\LogAuditUser.txt exists echo %HOMEDRIVE%\Windows\LogAuditUser.txt exists
) else ( ) else (
echo C:\Windows\LogAuditUser.txt does not exist echo %HOMEDRIVE%\Windows\LogAuditUser.txt does not exist
) )
if exist "C:\Windows\LogOobeSystem.txt" ( if exist "%HOMEDRIVE%\Windows\LogOobeSystem.txt" (
echo C:\Windows\LogOobeSystem.txt exists echo %HOMEDRIVE%\Windows\LogOobeSystem.txt exists
) else ( ) else (
echo C:\Windows\LogOobeSystem.txt does not exist echo %HOMEDRIVE%\Windows\LogOobeSystem.txt does not exist
) )
if exist "c:\windows\csup.txt" ( if exist "%HOMEDRIVE%\windows\csup.txt" (
echo c:\windows\csup.txt exists echo %HOMEDRIVE%\windows\csup.txt exists
) else ( ) else (
echo c:\windows\csup.txt does not exist echo %HOMEDRIVE%\windows\csup.txt does not exist
) )
if exist "c:\windows\LogFirstRun.txt" ( if exist "%HOMEDRIVE%\windows\LogFirstRun.txt" (
echo c:\windows\LogFirstRun.txt exists echo %HOMEDRIVE%\windows\LogFirstRun.txt exists
) else ( ) else (
echo c:\windows\LogFirstRun.txt does not exist echo %HOMEDRIVE%\windows\LogFirstRun.txt does not exist
) )
'@ '@
$checkInstall | Out-File -FilePath "$env:temp\checkinstall.cmd" -Force -Encoding Ascii $checkInstall | Out-File -FilePath "$env:temp\checkinstall.cmd" -Force -Encoding Ascii
@ -726,7 +761,7 @@ function New-FirstRun {
} }
} }
"FirstStartup has worked" | Out-File -FilePath c:\windows\LogFirstRun.txt -Append -NoClobber "FirstStartup has worked" | Out-File -FilePath "$env:HOMEDRIVE\windows\LogFirstRun.txt" -Append -NoClobber
$taskbarPath = "$env:AppData\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar" $taskbarPath = "$env:AppData\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar"
# Delete all files on the Taskbar # Delete all files on the Taskbar
@ -746,7 +781,7 @@ function New-FirstRun {
} }
} }
Remove-Item -Path "$env:USERPROFILE\Desktop\*.lnk" Remove-Item -Path "$env:USERPROFILE\Desktop\*.lnk"
Remove-Item -Path "C:\Users\Default\Desktop\*.lnk" Remove-Item -Path "$env:HOMEDRIVE\Users\Default\Desktop\*.lnk"
# ************************************************ # ************************************************
# Create WinUtil shortcut on the desktop # Create WinUtil shortcut on the desktop
@ -762,8 +797,8 @@ function New-FirstRun {
# Create a shortcut object # Create a shortcut object
$shortcut = $shell.CreateShortcut($shortcutPath) $shortcut = $shell.CreateShortcut($shortcutPath)
if (Test-Path -Path "c:\Windows\cttlogo.png") { if (Test-Path -Path "$env:HOMEDRIVE\Windows\cttlogo.png") {
$shortcut.IconLocation = "c:\Windows\cttlogo.png" $shortcut.IconLocation = "$env:HOMEDRIVE\Windows\cttlogo.png"
} }
# Set properties of the shortcut # Set properties of the shortcut
@ -783,8 +818,17 @@ function New-FirstRun {
# Done create WinUtil shortcut on the desktop # Done create WinUtil shortcut on the desktop
# ************************************************ # ************************************************
Start-Process explorer try
{
if ((Get-WindowsOptionalFeature -Online | Where-Object { $_.FeatureName -like "Recall" }).Count -gt 0)
{
Disable-WindowsOptionalFeature -Online -FeatureName "Recall" -Remove
}
}
catch
{
}
'@ '@
$firstRun | Out-File -FilePath "$env:temp\FirstStartup.ps1" -Force $firstRun | Out-File -FilePath "$env:temp\FirstStartup.ps1" -Force
} }

View File

@ -6,9 +6,6 @@ function Show-CustomDialog {
.DESCRIPTION .DESCRIPTION
This function creates a custom dialog box with the specified message and additional elements such as an image, heading, and an OK button. The dialog box is designed with a green border, rounded corners, and a black background. This function creates a custom dialog box with the specified message and additional elements such as an image, heading, and an OK button. The dialog box is designed with a green border, rounded corners, and a black background.
.PARAMETER Title
The Title to use for the dialog window's Title Bar, this will not be visible by the user, as window styling is set to None.
.PARAMETER Message .PARAMETER Message
The message to be displayed in the dialog box. The message to be displayed in the dialog box.
@ -19,102 +16,60 @@ function Show-CustomDialog {
The height of the custom dialog window. The height of the custom dialog window.
.PARAMETER FontSize .PARAMETER FontSize
The Font Size of message shown inside custom dialog window. The Font Size for text shown inside the custom dialog window.
.PARAMETER HeaderFontSize .PARAMETER HeaderFontSize
The Font Size for the Header of custom dialog window. The Font Size for the Header of the custom dialog window.
.PARAMETER LogoSize .PARAMETER IconSize
The Size of the Logo used inside the custom dialog window. The Size to use for Icon inside the custom dialog window.
.PARAMETER ForegroundColor
The Foreground Color of dialog window title & message.
.PARAMETER BackgroundColor
The Background Color of dialog window.
.PARAMETER BorderColor
The Color for dialog window border.
.PARAMETER ButtonBackgroundColor
The Background Color for Buttons in dialog window.
.PARAMETER ButtonForegroundColor
The Foreground Color for Buttons in dialog window.
.PARAMETER ShadowColor
The Color used when creating the Drop-down Shadow effect for dialog window.
.PARAMETER LogoColor
The Color of WinUtil Text found next to WinUtil's Logo inside dialog window.
.PARAMETER LinkForegroundColor
The Foreground Color for Links inside dialog window.
.PARAMETER LinkHoverForegroundColor
The Foreground Color for Links when the mouse pointer hovers over them inside dialog window.
.PARAMETER EnableScroll .PARAMETER EnableScroll
A flag indicating whether to enable scrolling if the content exceeds the window size. A flag indicating whether to enable scrolling if the content exceeds the window size.
.EXAMPLE .EXAMPLE
Show-CustomDialog -Title "My Custom Dialog" -Message "This is a custom dialog with a message and an image above." -Width 300 -Height 200 Show-CustomDialog -Message "This is a custom dialog with a message and an image above." -Width 300 -Height 200
Makes a new Custom Dialog with the title 'My Custom Dialog' and a message 'This is a custom dialog with a message and an image above.', with dimensions of 300 by 200 pixels.
Other styling options are grabbed from '$sync.Form.Resources' global variable.
.EXAMPLE
$foregroundColor = New-Object System.Windows.Media.SolidColorBrush("#0088e5")
$backgroundColor = New-Object System.Windows.Media.SolidColorBrush("#1e1e1e")
$linkForegroundColor = New-Object System.Windows.Media.SolidColorBrush("#0088e5")
$linkHoverForegroundColor = New-Object System.Windows.Media.SolidColorBrush("#005289")
Show-CustomDialog -Title "My Custom Dialog" -Message "This is a custom dialog with a message and an image above." -Width 300 -Height 200 -ForegroundColor $foregroundColor -BackgroundColor $backgroundColor -LinkForegroundColor $linkForegroundColor -LinkHoverForegroundColor $linkHoverForegroundColor
Makes a new Custom Dialog with the title 'My Custom Dialog' and a message 'This is a custom dialog with a message and an image above.', with dimensions of 300 by 200 pixels, with a link foreground (and general foreground) colors of '#0088e5', background color of '#1e1e1e', and Link Color on Hover of '005289', all of which are in Hexadecimal (the '#' Symbol is required by SolidColorBrush Constructor).
Other styling options are grabbed from '$sync.Form.Resources' global variable.
#> #>
param( param(
[string]$Title,
[string]$Message, [string]$Message,
[int]$Width = $sync.Form.Resources.CustomDialogWidth, [int]$Width = $sync.Form.Resources.CustomDialogWidth,
[int]$Height = $sync.Form.Resources.CustomDialogHeight, [int]$Height = $sync.Form.Resources.CustomDialogHeight,
[System.Windows.Media.FontFamily]$FontFamily = $sync.Form.Resources.FontFamily,
[int]$FontSize = $sync.Form.Resources.CustomDialogFontSize, [int]$FontSize = $sync.Form.Resources.CustomDialogFontSize,
[int]$HeaderFontSize = $sync.Form.Resources.CustomDialogFontSizeHeader, [int]$HeaderFontSize = $sync.Form.Resources.CustomDialogFontSizeHeader,
[int]$LogoSize = $sync.Form.Resources.CustomDialogLogoSize, [int]$IconSize = $sync.Form.Resources.CustomDialogLogoSize,
[System.Windows.Media.Color]$ShadowColor = "#AAAAAAAA",
[System.Windows.Media.SolidColorBrush]$LogoColor = $sync.Form.Resources.LabelboxForegroundColor,
[System.Windows.Media.SolidColorBrush]$BorderColor = $sync.Form.Resources.BorderColor,
[System.Windows.Media.SolidColorBrush]$ForegroundColor = $sync.Form.Resources.MainForegroundColor,
[System.Windows.Media.SolidColorBrush]$BackgroundColor = $sync.Form.Resources.MainBackgroundColor,
[System.Windows.Media.SolidColorBrush]$ButtonForegroundColor = $sync.Form.Resources.ButtonInstallForegroundColor,
[System.Windows.Media.SolidColorBrush]$ButtonBackgroundColor = $sync.Form.Resources.ButtonInstallBackgroundColor,
[System.Windows.Media.SolidColorBrush]$LinkForegroundColor = $sync.Form.Resources.LinkForegroundColor,
[System.Windows.Media.SolidColorBrush]$LinkHoverForegroundColor = $sync.Form.Resources.LinkHoverForegroundColor,
[bool]$EnableScroll = $false [bool]$EnableScroll = $false
) )
Add-Type -AssemblyName PresentationFramework
# Define theme colors
$foregroundColor = $sync.Form.Resources.MainForegroundColor
$backgroundColor = $sync.Form.Resources.MainBackgroundColor
$font = New-Object Windows.Media.FontFamily("Consolas")
$borderColor = $sync.Form.Resources.BorderColor # ButtonInstallBackgroundColor
$buttonBackgroundColor = $sync.Form.Resources.ButtonInstallBackgroundColor
$buttonForegroundColor = $sync.Form.Resources.ButtonInstallForegroundColor
$shadowColor = [Windows.Media.ColorConverter]::ConvertFromString("#AAAAAAAA")
$logocolor = $sync.Form.Resources.LabelboxForegroundColor
# Create a custom dialog window # Create a custom dialog window
$dialog = New-Object Windows.Window $dialog = New-Object Windows.Window
$dialog.Title = $Title $dialog.Title = "About"
$dialog.Height = $Height $dialog.Height = $Height
$dialog.Width = $Width $dialog.Width = $Width
$dialog.Margin = New-Object Windows.Thickness(10) # Add margin to the entire dialog box $dialog.Margin = New-Object Windows.Thickness(10) # Add margin to the entire dialog box
$dialog.WindowStyle = [Windows.WindowStyle]::None # Remove title bar and window controls $dialog.WindowStyle = [Windows.WindowStyle]::None # Remove title bar and window controls
$dialog.ResizeMode = [Windows.ResizeMode]::NoResize # Disable resizing $dialog.ResizeMode = [Windows.ResizeMode]::NoResize # Disable resizing
$dialog.WindowStartupLocation = [Windows.WindowStartupLocation]::CenterScreen # Center the window $dialog.WindowStartupLocation = [Windows.WindowStartupLocation]::CenterScreen # Center the window
$dialog.Foreground = $ForegroundColor $dialog.Foreground = $foregroundColor
$dialog.Background = $BackgroundColor $dialog.Background = $backgroundColor
$dialog.FontFamily = $FontFamily $dialog.FontFamily = $font
$dialog.FontSize = $FontSize $dialog.FontSize = $FontSize
# Create a Border for the green edge with rounded corners # Create a Border for the green edge with rounded corners
$border = New-Object Windows.Controls.Border $border = New-Object Windows.Controls.Border
$border.BorderBrush = $BorderColor $border.BorderBrush = $borderColor
$border.BorderThickness = New-Object Windows.Thickness(1) # Adjust border thickness as needed $border.BorderThickness = New-Object Windows.Thickness(1) # Adjust border thickness as needed
$border.CornerRadius = New-Object Windows.CornerRadius(10) # Adjust the radius for rounded corners $border.CornerRadius = New-Object Windows.CornerRadius(10) # Adjust the radius for rounded corners
@ -134,7 +89,7 @@ function Show-CustomDialog {
$grid = New-Object Windows.Controls.Grid $grid = New-Object Windows.Controls.Grid
$border.Child = $grid $border.Child = $grid
# Uncomment the following line to show gridlines # Add the following line to show gridlines
#$grid.ShowGridLines = $true #$grid.ShowGridLines = $true
# Add the following line to set the background color of the grid # Add the following line to set the background color of the grid
@ -147,6 +102,7 @@ function Show-CustomDialog {
$border.HorizontalAlignment = [Windows.HorizontalAlignment]::Stretch $border.HorizontalAlignment = [Windows.HorizontalAlignment]::Stretch
$border.VerticalAlignment = [Windows.VerticalAlignment]::Stretch $border.VerticalAlignment = [Windows.VerticalAlignment]::Stretch
# Set up Row Definitions # Set up Row Definitions
$row0 = New-Object Windows.Controls.RowDefinition $row0 = New-Object Windows.Controls.RowDefinition
$row0.Height = [Windows.GridLength]::Auto $row0.Height = [Windows.GridLength]::Auto
@ -173,18 +129,17 @@ function Show-CustomDialog {
[Windows.Controls.Grid]::SetRow($stackPanel, 0) # Set the row to the second row (0-based index) [Windows.Controls.Grid]::SetRow($stackPanel, 0) # Set the row to the second row (0-based index)
# Add SVG path to the stack panel # Add SVG path to the stack panel
$stackPanel.Children.Add((Invoke-WinUtilAssets -Type "logo" -Size $LogoSize)) $stackPanel.Children.Add((Invoke-WinUtilAssets -Type "logo" -Size 25))
# Add "Winutil" text # Add "Winutil" text
$winutilTextBlock = New-Object Windows.Controls.TextBlock $winutilTextBlock = New-Object Windows.Controls.TextBlock
$winutilTextBlock.Text = "Winutil" $winutilTextBlock.Text = "Winutil"
$winutilTextBlock.FontSize = $HeaderFontSize $winutilTextBlock.FontSize = $HeaderFontSize
$winutilTextBlock.Foreground = $LogoColor $winutilTextBlock.Foreground = $logocolor
$winutilTextBlock.Margin = New-Object Windows.Thickness(10, 10, 10, 5) # Add margins around the text block $winutilTextBlock.Margin = New-Object Windows.Thickness(10, 10, 10, 5) # Add margins around the text block
$stackPanel.Children.Add($winutilTextBlock) $stackPanel.Children.Add($winutilTextBlock)
# Add TextBlock for information with text wrapping and margins # Add TextBlock for information with text wrapping and margins
$messageTextBlock = New-Object Windows.Controls.TextBlock $messageTextBlock = New-Object Windows.Controls.TextBlock
$messageTextBlock.FontSize = $FontSize
$messageTextBlock.TextWrapping = [Windows.TextWrapping]::Wrap # Enable text wrapping $messageTextBlock.TextWrapping = [Windows.TextWrapping]::Wrap # Enable text wrapping
$messageTextBlock.HorizontalAlignment = [Windows.HorizontalAlignment]::Left $messageTextBlock.HorizontalAlignment = [Windows.HorizontalAlignment]::Left
$messageTextBlock.VerticalAlignment = [Windows.VerticalAlignment]::Top $messageTextBlock.VerticalAlignment = [Windows.VerticalAlignment]::Top
@ -207,7 +162,7 @@ function Show-CustomDialog {
$hyperlink.NavigateUri = New-Object System.Uri($match.Groups[1].Value) $hyperlink.NavigateUri = New-Object System.Uri($match.Groups[1].Value)
$hyperlink.Inlines.Add($match.Groups[2].Value) $hyperlink.Inlines.Add($match.Groups[2].Value)
$hyperlink.TextDecorations = [Windows.TextDecorations]::None # Remove underline $hyperlink.TextDecorations = [Windows.TextDecorations]::None # Remove underline
$hyperlink.Foreground = $LinkForegroundColor $hyperlink.Foreground = $sync.Form.Resources.LinkForegroundColor
$hyperlink.Add_Click({ $hyperlink.Add_Click({
param($sender, $args) param($sender, $args)
@ -215,15 +170,11 @@ function Show-CustomDialog {
}) })
$hyperlink.Add_MouseEnter({ $hyperlink.Add_MouseEnter({
param($sender, $args) param($sender, $args)
$sender.Foreground = $LinkHoverForegroundColor $sender.Foreground = $sync.Form.Resources.LinkHoverForegroundColor
$sender.FontSize = ($FontSize + ($FontSize / 4))
$sender.FontWeight = "SemiBold"
}) })
$hyperlink.Add_MouseLeave({ $hyperlink.Add_MouseLeave({
param($sender, $args) param($sender, $args)
$sender.Foreground = $LinkForegroundColor $sender.Foreground = $sync.Form.Resources.LinkForegroundColor
$sender.FontSize = $FontSize
$sender.FontWeight = "Normal"
}) })
$messageTextBlock.Inlines.Add($hyperlink) $messageTextBlock.Inlines.Add($hyperlink)
@ -267,7 +218,7 @@ function Show-CustomDialog {
$okButton.Margin = New-Object Windows.Thickness(0, 0, 0, 10) $okButton.Margin = New-Object Windows.Thickness(0, 0, 0, 10)
$okButton.Background = $buttonBackgroundColor $okButton.Background = $buttonBackgroundColor
$okButton.Foreground = $buttonForegroundColor $okButton.Foreground = $buttonForegroundColor
$okButton.BorderBrush = $BorderColor $okButton.BorderBrush = $borderColor
$okButton.Add_Click({ $okButton.Add_Click({
$dialog.Close() $dialog.Close()
}) })

View File

@ -51,10 +51,6 @@ public class PowerManagement {
$index = $sync.MicrowinWindowsFlavors.SelectedValue.Split(":")[0].Trim() $index = $sync.MicrowinWindowsFlavors.SelectedValue.Split(":")[0].Trim()
Write-Host "Index chosen: '$index' from $($sync.MicrowinWindowsFlavors.SelectedValue)" Write-Host "Index chosen: '$index' from $($sync.MicrowinWindowsFlavors.SelectedValue)"
$keepPackages = $sync.WPFMicrowinKeepProvisionedPackages.IsChecked
$keepProvisionedPackages = $sync.WPFMicrowinKeepAppxPackages.IsChecked
$keepDefender = $sync.WPFMicrowinKeepDefender.IsChecked
$keepEdge = $sync.WPFMicrowinKeepEdge.IsChecked
$copyToUSB = $sync.WPFMicrowinCopyToUsb.IsChecked $copyToUSB = $sync.WPFMicrowinCopyToUsb.IsChecked
$injectDrivers = $sync.MicrowinInjectDrivers.IsChecked $injectDrivers = $sync.MicrowinInjectDrivers.IsChecked
$importDrivers = $sync.MicrowinImportDrivers.IsChecked $importDrivers = $sync.MicrowinImportDrivers.IsChecked
@ -91,6 +87,14 @@ public class PowerManagement {
return return
} }
# Detect whether the image to process contains Windows 10 and show warning
if ((Test-CompatibleImage $imgVersion $([System.Version]::new(10,0,21996,1))) -eq $false) {
$msg = "Windows 10 has been detected in the image you want to process. While you can continue, Windows 10 is not a recommended target for MicroWin, and you may not get the full experience."
$dlg_msg = $msg
Write-Host $msg
[System.Windows.MessageBox]::Show($dlg_msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Exclamation)
}
$mountDirExists = Test-Path $mountDir $mountDirExists = Test-Path $mountDir
$scratchDirExists = Test-Path $scratchDir $scratchDirExists = Test-Path $scratchDir
if (-not $mountDirExists -or -not $scratchDirExists) { if (-not $mountDirExists -or -not $scratchDirExists) {
@ -238,6 +242,9 @@ public class PowerManagement {
# Write-Host Error code $LASTEXITCODE # Write-Host Error code $LASTEXITCODE
Write-Host "Done disabling Teams" Write-Host "Done disabling Teams"
Write-Host "Fix Windows Volume Mixer Issue"
reg add "HKLM\zNTUSER\Software\Microsoft\Internet Explorer\LowRegistry\Audio\PolicyConfig\PropertyStore" /f
Write-Host "Bypassing system requirements (system image)" Write-Host "Bypassing system requirements (system image)"
reg add "HKLM\zDEFAULT\Control Panel\UnsupportedHardwareNotificationCache" /v "SV1" /t REG_DWORD /d 0 /f reg add "HKLM\zDEFAULT\Control Panel\UnsupportedHardwareNotificationCache" /v "SV1" /t REG_DWORD /d 0 /f
reg add "HKLM\zDEFAULT\Control Panel\UnsupportedHardwareNotificationCache" /v "SV2" /t REG_DWORD /d 0 /f reg add "HKLM\zDEFAULT\Control Panel\UnsupportedHardwareNotificationCache" /v "SV2" /t REG_DWORD /d 0 /f
@ -289,6 +296,19 @@ public class PowerManagement {
reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize" /v "AppsUseLightTheme" /t REG_DWORD /d 0 /f reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize" /v "AppsUseLightTheme" /t REG_DWORD /d 0 /f
reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize" /v "SystemUsesLightTheme" /t REG_DWORD /d 0 /f reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize" /v "SystemUsesLightTheme" /t REG_DWORD /d 0 /f
if ((Test-CompatibleImage $imgVersion $([System.Version]::new(10,0,21996,1))) -eq $false) {
# We're dealing with Windows 10. Configure sane desktop settings. NOTE: even though stuff to disable News and Interests is there,
# it doesn't seem to work, and I don't want to waste more time dealing with an operating system that will lose support in a year (2025)
# I invite anyone to work on improving stuff for News and Interests, but that won't be me!
Write-Host "Disabling Search Highlights..."
reg add "HKLM\zNTUSER\SOFTWARE\Microsoft\Windows\CurrentVersion\Feeds\DSB" /v "ShowDynamicContent" /t REG_DWORD /d 0 /f
reg add "HKLM\zNTUSER\SOFTWARE\Microsoft\Windows\CurrentVersion\SearchSettings" /v "IsDynamicSearchBoxEnabled" /t REG_DWORD /d 0 /f
reg add "HKLM\zSOFTWARE\Policies\Microsoft\Dsh" /v "AllowNewsAndInterests" /t REG_DWORD /d 0 /f
reg add "HKLM\zNTUSER\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" /v "TraySearchBoxVisible" /t REG_DWORD /d 1 /f
}
} catch { } catch {
Write-Error "An unexpected error occurred: $_" Write-Error "An unexpected error occurred: $_"
} finally { } finally {

View File

@ -1,91 +0,0 @@
function Invoke-WPFPopup {
param (
[Parameter(position=0)]
[ValidateSet("Show","Hide","Toggle", ErrorMessage="Action '{0}' is not part of the valid set '{1}'.")]
[string]$Action = "",
[Parameter(position=1)]
[string[]]$Popups = @(),
[Parameter(position=2)]
[ValidateScript({
$PossibleActions = @("Show", "Hide", "Toggle")
[hashtable]$UnExpectedPairs = @{}
Foreach ($pair in $_.GetEnumerator()) {
$key = $pair.Name
$value = $pair.Value
if (-not ($value -in $PossibleActions)) {
$UnExpectedPairs.Add("$key", "$value")
}
}
if ($UnExpectedPairs.Count -gt 0) {
$UnExpectedPairsAsString = "@{"
Foreach ($pair in $UnExpectedPairs.GetEnumerator()) { $UnExpectedPairsAsString += "`"$($pair.Name)`" = `"$($pair.Value)`"; " }
$UnExpectedPairsAsString = $UnExpectedPairsAsString -replace (';\s*$', '')
$UnExpectedPairsAsString += "}"
throw "Found Unexpected pair(s), these Popup & Action pair(s) are: $UnExpectedPairsAsString"
}
# Return true for passing validation checks
$true
})]
[hashtable]$PopupActionTable = @{}
)
if ($PopupActionTable.Count -eq 0 -and $Action -eq "" -and $Popups.Count -eq 0) {
throw [GenericException]::new("No Parameter was provided, please use either 'PopupActionTable' on its own, or use 'Action' and 'Popups' on their own, depending on your use case.")
}
if ($PopupActionTable.Count -gt 0 -and ($Action -ne "" -or $Popups.Count -gt 0)) {
throw [GenericException]::new("Only use 'PopupActionTable' on its own, or use 'Action' and 'Popups' on their own, depending on your use case.")
}
$PopupsNotFound = [System.Collections.Generic.List[string]]::new($Popups.Count)
if ($PopupActionTable.Count -gt 0) {
Foreach ($popupActionPair in $PopupActionTable.GetEnumerator()) {
$popup = $popupActionPair.Name + "Popup"
$action = $popupActionPair.Value
if ($sync.$popup -eq $null) {
$PopupsNotFound.Add("$popup") | Out-Null
continue
}
switch ($action) {
'Show' { $actionAsBool = $true }
'Hide' { $actionAsBool = $false }
'Toggle' { $actionAsBool = -not $sync.$popup.IsOpen }
default { throw [GenericException]::new("Action can only be `"Show`" or `"Hide`" or `"Toggle`".") }
}
$sync.$popup.IsOpen = $actionAsBool
}
} else {
if ($Action -eq "" -or $Popups.Count -eq 0) {
throw [GenericException]::new("Please provide both the 'Action' and 'Popups' Parameters, with the appropriate values foreach parameter.")
}
Foreach ($popup in $Popups) {
$popup += "Popup"
if ($sync.$popup -eq $null) {
$PopupsNotFound.Add("$popup") | Out-Null
continue
}
switch ($action) {
'Show' { $actionAsBool = $true }
'Hide' { $actionAsBool = $false }
'Toggle' { $actionAsBool = -not $sync.$popup.IsOpen }
default { throw [GenericException]::new("Action can only be `"Show`" or `"Hide`" or `"Toggle`".") }
}
$sync.$popup.IsOpen = $actionAsBool
}
}
if ($PopupsNotFound.Count -gt 0) {
$PopupsNotFoundAsString = "@("
Foreach ($popupNotFound in $PopupsNotFound) {
$PopupsNotFoundAsString += "$popupNotFound"
$PopupsNotFoundAsString += ", "
}
$PopupsNotFoundAsString = $PopupsNotFoundAsString -replace (',\s*$', '')
$PopupsNotFoundAsString += ")"
throw [GenericException]::new("Could not find $PopupsNotFoundAsString Popups in `$sync variable.")
}
}

View File

@ -142,7 +142,7 @@ function Invoke-WPFUIElements {
$label = New-Object Windows.Controls.Label $label = New-Object Windows.Controls.Label
$label.Content = $category -replace ".*__", "" $label.Content = $category -replace ".*__", ""
$label.FontSize = $theme.HeadingFontSize $label.FontSize = $theme.FontSizeHeading
$label.FontFamily = $theme.HeaderFontFamily $label.FontFamily = $theme.HeaderFontFamily
$stackPanel.Children.Add($label) | Out-Null $stackPanel.Children.Add($label) | Out-Null

View File

@ -33,16 +33,19 @@ $sync.runspace.Open()
class WingetFailedInstall : Exception { class WingetFailedInstall : Exception {
[string]$additionalData [string]$additionalData
WingetFailedInstall($Message) : base($Message) {} WingetFailedInstall($Message) : base($Message) {}
} }
class ChocoFailedInstall : Exception { class ChocoFailedInstall : Exception {
[string]$additionalData [string]$additionalData
ChocoFailedInstall($Message) : base($Message) {} ChocoFailedInstall($Message) : base($Message) {}
} }
class GenericException : Exception { class GenericException : Exception {
[string]$additionalData [string]$additionalData
GenericException($Message) : base($Message) {} GenericException($Message) : base($Message) {}
} }
@ -251,7 +254,12 @@ $commonKeyEvents = {
$sync["Form"].Add_PreViewKeyDown($commonKeyEvents) $sync["Form"].Add_PreViewKeyDown($commonKeyEvents)
$sync["Form"].Add_MouseLeftButtonDown({ $sync["Form"].Add_MouseLeftButtonDown({
Invoke-WPFPopup -Action "Hide" -Popups @("Settings", "Theme") # Hide Settings and Theme Popup on click anywhere else
if ($sync.SettingsButton.IsOpen -or
$sync.ThemePopup.IsOpen) {
$sync.SettingsPopup.IsOpen = $false
$sync.ThemePopup.IsOpen = $false
}
$sync["Form"].DragMove() $sync["Form"].DragMove()
}) })
@ -269,7 +277,12 @@ $sync["Form"].Add_MouseDoubleClick({
$sync["Form"].Add_Deactivated({ $sync["Form"].Add_Deactivated({
Write-Debug "WinUtil lost focus" Write-Debug "WinUtil lost focus"
Invoke-WPFPopup -Action "Hide" -Popups @("Settings", "Theme") # Hide Settings and Theme Popup on Winutil Focus Loss
if ($sync.SettingsButton.IsOpen -or
$sync.ThemePopup.IsOpen) {
$sync.SettingsPopup.IsOpen = $false
$sync.ThemePopup.IsOpen = $false
}
}) })
$sync["Form"].Add_ContentRendered({ $sync["Form"].Add_ContentRendered({
@ -397,10 +410,8 @@ $sync["ISOmanual"].add_Checked({
$sync["ISOLanguage"].Visibility = [System.Windows.Visibility]::Collapsed $sync["ISOLanguage"].Visibility = [System.Windows.Visibility]::Collapsed
}) })
$sync["ISORelease"].Items.Add("23H2") | Out-Null $sync["ISORelease"].Items.Add("24H2") | Out-Null
$sync["ISORelease"].Items.Add("22H2") | Out-Null $sync["ISORelease"].SelectedItem = "24H2"
$sync["ISORelease"].Items.Add("21H2") | Out-Null
$sync["ISORelease"].SelectedItem = "23H2"
$sync["ISOLanguage"].Items.Add("System Language ($(Get-FidoLangFromCulture -langName $((Get-Culture).Name)))") | Out-Null $sync["ISOLanguage"].Items.Add("System Language ($(Get-FidoLangFromCulture -langName $((Get-Culture).Name)))") | Out-Null
if ($currentCulture -ne "English International") { if ($currentCulture -ne "English International") {
@ -510,79 +521,101 @@ Set-WinUtilTaskbaritem -overlay "logo"
$sync["Form"].Add_Activated({ $sync["Form"].Add_Activated({
Set-WinUtilTaskbaritem -overlay "logo" Set-WinUtilTaskbaritem -overlay "logo"
}) })
# Define event handler for ThemeButton click
$sync["ThemeButton"].Add_Click({ $sync["ThemeButton"].Add_Click({
Write-Debug "ThemeButton clicked" if ($sync.ThemePopup.IsOpen) {
Invoke-WPFPopup -PopupActionTable @{ "Settings" = "Hide"; "Theme" = "Toggle" } $sync.ThemePopup.IsOpen = $false
$_.Handled = $false }
else{
$sync.ThemePopup.IsOpen = $true
}
$sync.SettingsPopup.IsOpen = $false
}) })
# Define event handlers for menu items
$sync["AutoThemeMenuItem"].Add_Click({ $sync["AutoThemeMenuItem"].Add_Click({
Write-Debug "About clicked" $sync.ThemePopup.IsOpen = $false
Invoke-WPFPopup -Action "Hide" -Popups @("Theme")
Invoke-WinutilThemeChange -theme "Auto" Invoke-WinutilThemeChange -theme "Auto"
$_.Handled = $false $_.Handled = $false
}) })
# Define event handlers for menu items
$sync["DarkThemeMenuItem"].Add_Click({ $sync["DarkThemeMenuItem"].Add_Click({
Write-Debug "Dark Theme clicked" $sync.ThemePopup.IsOpen = $false
Invoke-WPFPopup -Action "Hide" -Popups @("Theme")
Invoke-WinutilThemeChange -theme "Dark" Invoke-WinutilThemeChange -theme "Dark"
$_.Handled = $false $_.Handled = $false
}) })
# Define event handlers for menu items
$sync["LightThemeMenuItem"].Add_Click({ $sync["LightThemeMenuItem"].Add_Click({
Write-Debug "Light Theme clicked" $sync.ThemePopup.IsOpen = $false
Invoke-WPFPopup -Action "Hide" -Popups @("Theme")
Invoke-WinutilThemeChange -theme "Light" Invoke-WinutilThemeChange -theme "Light"
$_.Handled = $false $_.Handled = $false
}) })
# Define event handler for button click
$sync["SettingsButton"].Add_Click({ $sync["SettingsButton"].Add_Click({
Write-Debug "SettingsButton clicked" Write-Debug "SettingsButton clicked"
Invoke-WPFPopup -PopupActionTable @{ "Settings" = "Toggle"; "Theme" = "Hide" } if ($sync.SettingsPopup.IsOpen) {
$sync.SettingsPopup.IsOpen = $false
}
else{
$sync.SettingsPopup.IsOpen = $true
}
$sync.ThemePopup.IsOpen = $false
$_.Handled = $false $_.Handled = $false
}) })
# Define event handlers for menu items
$sync["ImportMenuItem"].Add_Click({ $sync["ImportMenuItem"].Add_Click({
# Handle Import menu item click
Write-Debug "Import clicked" Write-Debug "Import clicked"
Invoke-WPFPopup -Action "Hide" -Popups @("Settings") $sync["SettingsPopup"].IsOpen = $false
Invoke-WPFImpex -type "import" Invoke-WPFImpex -type "import"
$_.Handled = $false $_.Handled = $false
}) })
$sync["ExportMenuItem"].Add_Click({ $sync["ExportMenuItem"].Add_Click({
# Handle Export menu item click
Write-Debug "Export clicked" Write-Debug "Export clicked"
Invoke-WPFPopup -Action "Hide" -Popups @("Settings") $sync["SettingsPopup"].IsOpen = $false
Invoke-WPFImpex -type "export" Invoke-WPFImpex -type "export"
$_.Handled = $false $_.Handled = $false
}) })
$sync["AboutMenuItem"].Add_Click({
Write-Debug "About clicked"
Invoke-WPFPopup -Action "Hide" -Popups @("Settings")
$sync["AboutMenuItem"].Add_Click({
# Handle Export menu item click
Write-Debug "About clicked"
$sync["SettingsPopup"].IsOpen = $false
$authorInfo = @" $authorInfo = @"
Author : <a href="https://github.com/ChrisTitusTech">@christitustech</a> Author : <a href="https://github.com/ChrisTitusTech">@christitustech</a>
Runspace : <a href="https://github.com/DeveloperDurp">@DeveloperDurp</a> Runspace : <a href="https://github.com/DeveloperDurp">@DeveloperDurp</a>
MicroWin : <a href="https://github.com/KonTy">@KonTy</a>, <a href="https://github.com/CodingWonders">@CodingWonders</a> MicroWin : <a href="https://github.com/KonTy">@KonTy</a>
GitHub : <a href="https://github.com/ChrisTitusTech/winutil">ChrisTitusTech/winutil</a> GitHub : <a href="https://github.com/ChrisTitusTech/winutil">ChrisTitusTech/winutil</a>
Version : <a href="https://github.com/ChrisTitusTech/winutil/releases/tag/$($sync.version)">$($sync.version)</a> Version : <a href="https://github.com/ChrisTitusTech/winutil/releases/tag/$($sync.version)">$($sync.version)</a>
"@ "@
Show-CustomDialog -Title "About" -Message $authorInfo
})
$sync["SponsorMenuItem"].Add_Click({
Write-Debug "Sponsors clicked"
Invoke-WPFPopup -Action "Hide" -Popups @("Settings")
Show-CustomDialog -Message $authorInfo -LogoSize $LogoSize
})
$sync["SponsorMenuItem"].Add_Click({
# Handle Export menu item click
Write-Debug "Sponsors clicked"
$sync["SettingsPopup"].IsOpen = $false
$authorInfo = @" $authorInfo = @"
<a href="https://github.com/sponsors/ChrisTitusTech">Current sponsors for ChrisTitusTech:</a> <a href="https://github.com/sponsors/ChrisTitusTech">Current sponsors for ChrisTitusTech:</a>
"@ "@
$authorInfo += "`n" $authorInfo += "`n"
try { try {
# Call the function to get the sponsors
$sponsors = Invoke-WinUtilSponsors $sponsors = Invoke-WinUtilSponsors
foreach ($sponsor in $sponsors) {
$authorInfo += "<a href=`"https://github.com/sponsors/ChrisTitusTech`">$sponsor</a>`n" # Append the sponsors to the authorInfo
} $sponsors | ForEach-Object { $authorInfo += "$_`n" }
} catch { } catch {
$authorInfo += "An error occurred while fetching or processing the sponsors: $_`n" $authorInfo += "An error occurred while fetching or processing the sponsors: $_`n"
} }
Show-CustomDialog -Title "Sponsors" -Message $authorInfo -EnableScroll $true
Show-CustomDialog -Message $authorInfo -EnableScroll $true
}) })
$sync["Form"].ShowDialog() | out-null $sync["Form"].ShowDialog() | out-null

View File

@ -1004,19 +1004,19 @@
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Border Grid.Row="0" Grid.Column="0" Style="{StaticResource BorderStyle}"> <Border Grid.Row="0" Grid.Column="0" Style="{StaticResource BorderStyle}">
<StackPanel Background="{DynamicResource MainBackgroundColor}" SnapsToDevicePixels="True"> <StackPanel Background="{DynamicResource MainBackgroundColor}" SnapsToDevicePixels="True">
<Button Name="WPFUpdatesdefault" FontSize="{DynamicResource ConfigUpdateButtonFontSize}" Height="Auto" Width="Auto" Content="Default (Out of Box) Settings" Margin="20,4,20,10" Padding="10"/> <Button Name="WPFUpdatesdefault" FontSize="{DynamicResource ConfigTabButtonFontSize}" Height="Auto" Width="Auto" Content="Default (Out of Box) Settings" Margin="20,4,20,10" Padding="10"/>
<TextBlock Foreground="{DynamicResource ComboBoxForegroundColor}" Margin="20,0,20,0" Padding="10" TextWrapping="WrapWithOverflow" MaxWidth="300">This is the default settings that come with Windows. <LineBreak/><LineBreak/> No modifications are made and will remove any custom windows update settings.<LineBreak/><LineBreak/>Note: If you still encounter update errors, reset all updates in the config tab. That will restore ALL Microsoft Update Services from their servers and reinstall them to default settings.</TextBlock> <TextBlock Foreground="{DynamicResource ComboBoxForegroundColor}" Margin="20,0,20,0" Padding="10" TextWrapping="WrapWithOverflow" MaxWidth="300">This is the default settings that come with Windows. <LineBreak/><LineBreak/> No modifications are made and will remove any custom windows update settings.<LineBreak/><LineBreak/>Note: If you still encounter update errors, reset all updates in the config tab. That will restore ALL Microsoft Update Services from their servers and reinstall them to default settings.</TextBlock>
</StackPanel> </StackPanel>
</Border> </Border>
<Border Grid.Row="0" Grid.Column="1" Style="{StaticResource BorderStyle}"> <Border Grid.Row="0" Grid.Column="1" Style="{StaticResource BorderStyle}">
<StackPanel Background="{DynamicResource MainBackgroundColor}" SnapsToDevicePixels="True"> <StackPanel Background="{DynamicResource MainBackgroundColor}" SnapsToDevicePixels="True">
<Button Name="WPFUpdatessecurity" FontSize="{DynamicResource ConfigUpdateButtonFontSize}" Height="Auto" Width="Auto" Content="Security (Recommended) Settings" Margin="20,4,20,10" Padding="10"/> <Button Name="WPFUpdatessecurity" FontSize="{DynamicResource ConfigTabButtonFontSize}" Height="Auto" Width="Auto" Content="Security (Recommended) Settings" Margin="20,4,20,10" Padding="10"/>
<TextBlock Foreground="{DynamicResource ComboBoxForegroundColor}" Margin="20,0,20,0" Padding="10" TextWrapping="WrapWithOverflow" MaxWidth="300">This is my recommended setting I use on all computers.<LineBreak/><LineBreak/> It will delay feature updates by 2 years and will install security updates 4 days after release.<LineBreak/><LineBreak/>Feature Updates: Adds features and often bugs to systems when they are released. You want to delay these as long as possible.<LineBreak/><LineBreak/>Security Updates: Typically these are pressing security flaws that need to be patched quickly. You only want to delay these a couple of days just to see if they are safe and don't break other systems. You don't want to go without these for ANY extended periods of time.</TextBlock> <TextBlock Foreground="{DynamicResource ComboBoxForegroundColor}" Margin="20,0,20,0" Padding="10" TextWrapping="WrapWithOverflow" MaxWidth="300">This is my recommended setting I use on all computers.<LineBreak/><LineBreak/> It will delay feature updates by 2 years and will install security updates 4 days after release.<LineBreak/><LineBreak/>Feature Updates: Adds features and often bugs to systems when they are released. You want to delay these as long as possible.<LineBreak/><LineBreak/>Security Updates: Typically these are pressing security flaws that need to be patched quickly. You only want to delay these a couple of days just to see if they are safe and don't break other systems. You don't want to go without these for ANY extended periods of time.</TextBlock>
</StackPanel> </StackPanel>
</Border> </Border>
<Border Grid.Row="0" Grid.Column="2" Style="{StaticResource BorderStyle}"> <Border Grid.Row="0" Grid.Column="2" Style="{StaticResource BorderStyle}">
<StackPanel Background="{DynamicResource MainBackgroundColor}" SnapsToDevicePixels="True"> <StackPanel Background="{DynamicResource MainBackgroundColor}" SnapsToDevicePixels="True">
<Button Name="WPFUpdatesdisable" FontSize="{DynamicResource ConfigUpdateButtonFontSize}" Height="Auto" Width="Auto" Content="Disable ALL Updates (NOT RECOMMENDED!)" Margin="20,4,20,10" Padding="10,10,10,10"/> <Button Name="WPFUpdatesdisable" FontSize="{DynamicResource ConfigTabButtonFontSize}" Height="Auto" Width="Auto" Content="Disable ALL Updates (NOT RECOMMENDED!)" Margin="20,4,20,10" Padding="10,10,10,10"/>
<TextBlock Foreground="{DynamicResource ComboBoxForegroundColor}" Margin="20,0,20,0" Padding="10" TextWrapping="WrapWithOverflow" MaxWidth="300">This completely disables ALL Windows Updates and is NOT RECOMMENDED.<LineBreak/><LineBreak/> However, it can be suitable if you use your system for a select purpose and do not actively browse the internet. <LineBreak/><LineBreak/>Note: Your system will be easier to hack and infect without security updates.</TextBlock> <TextBlock Foreground="{DynamicResource ComboBoxForegroundColor}" Margin="20,0,20,0" Padding="10" TextWrapping="WrapWithOverflow" MaxWidth="300">This completely disables ALL Windows Updates and is NOT RECOMMENDED.<LineBreak/><LineBreak/> However, it can be suitable if you use your system for a select purpose and do not actively browse the internet. <LineBreak/><LineBreak/>Note: Your system will be easier to hack and infect without security updates.</TextBlock>
<TextBlock Text=" " Margin="20,0,20,0" Padding="10" TextWrapping="WrapWithOverflow" MaxWidth="300"/> <TextBlock Text=" " Margin="20,0,20,0" Padding="10" TextWrapping="WrapWithOverflow" MaxWidth="300"/>
</StackPanel> </StackPanel>
@ -1040,7 +1040,7 @@
HorizontalAlignment="Stretch"> HorizontalAlignment="Stretch">
<StackPanel Name="MicrowinMain" Background="{DynamicResource MainBackgroundColor}" SnapsToDevicePixels="True" Grid.Column="0" Grid.Row="0"> <StackPanel Name="MicrowinMain" Background="{DynamicResource MainBackgroundColor}" SnapsToDevicePixels="True" Grid.Column="0" Grid.Row="0">
<StackPanel Background="Transparent" SnapsToDevicePixels="True" Margin="1"> <StackPanel Background="Transparent" SnapsToDevicePixels="True" Margin="1">
<CheckBox x:Name="WPFMicrowinDownloadFromGitHub" Content="Download oscdimg.exe from CTT Github repo" IsChecked="False" Margin="{DynamicResource MicrowinCheckBoxMargin}" /> <CheckBox x:Name="WPFMicrowinDownloadFromGitHub" Content="Download oscdimg.exe from CTT Github repo" IsChecked="True" Margin="{DynamicResource MicrowinCheckBoxMargin}" />
<TextBlock Margin="5" Padding="1" TextWrapping="Wrap" Foreground="{DynamicResource ComboBoxForegroundColor}"> <TextBlock Margin="5" Padding="1" TextWrapping="Wrap" Foreground="{DynamicResource ComboBoxForegroundColor}">
Choose a Windows ISO file that you've downloaded <LineBreak/> Choose a Windows ISO file that you've downloaded <LineBreak/>
Check the status in the console Check the status in the console