From 68927444b66fbdb91f92fd45450bb7c37a9a9ebf Mon Sep 17 00:00:00 2001 From: Chris Titus Date: Thu, 13 Jul 2023 15:46:00 -0500 Subject: [PATCH] 05 16 23 testing (#881) * Fix power profile (#766) (#767) * Fix power profile query * fix syntax * fix * Update Invoke-WPFUltimatePerformance.ps1 * Update winutil.ps1 * power profile fix * add reset network with netsh (#768) * add verbose logon (#773) * add verbose logon Enable or disable verbose sign in status messages. Verbose status messages may be helpful when you are troubleshooting slow startup, shutdown, logon, or logoff behavior. * compress-into-one-checkbox * compile winutil.ps1 * Update README.md (#774) * Update README.md * Update README.md * Adding 3 programs to the install tab (#789) * Prism Launcher - Custom FOSS minecraft launcher * Gsudo - Command line program that allows you to elevate a program as admin. * WingetUI - Graphical front end for winget, chochlatey and scoop Co-authored-by: Chris Titus * add undoscript feature + implement it on every tweaks (#776) * add undoscript feature + implement it on right click menu - add undoscript feature - add undo for right click menu to go back to windows 11 default right click menu by implementing undoscript feature * undoscript for WPFMiscTweaksDisplay * undoscript for WPFEssTweaksRemoveEdge * undoscript for WPFEssTweaksRemoveCortana * undoscript for WPFEssTweaksStorage * Update Invoke-WinUtilTweaks.ps1 thanks to @DeveloperDurp * compile * Fix packages name (#815) * fix-winrar_package_name * fix-vc++_package_name * fix #687 * implement check for admin (#818) check if script is running as admin or not and if not then it attempt to relaunch with admin privilege. * add "NetFx4Extended-ASPNET45" under dotnet features (#831) * add-docker-desktop (#834) Co-authored-by: Chris Titus * Fix 'Get Installed' for multiple-dependency apps (#835) * Update winutil.ps1 (#858) fix typos * Fixing AcceptEULA on Autologin * Program Update: Replace Origin with EA App #544 (#875) * New Theme support, initial functions. (#878) * Fix power profile (#766) * Fix power profile query * fix syntax * fix * Update Invoke-WPFUltimatePerformance.ps1 * Update winutil.ps1 * power profile fix * Adding Nomacs Opensource free and fast Image viewer * Adding theme support Later when this is tested well, we can do one of 2 things. 1. Pass theme on a command line so people with bad vision will have an option to have a better (more visible theme) 2. Create a drop down with themes and a save button which would save it ti some local config file * Fix for the compile script --------- Co-authored-by: Chris Titus * Dark Mode Enable * auto detect theme --------- Co-authored-by: Padsala Tushal <57517785+padsalatushal@users.noreply.github.com> Co-authored-by: Taken Co-authored-by: Yurin Doctrine Co-authored-by: Aaron <54756786+AaronVickers@users.noreply.github.com> Co-authored-by: Sahil Jassal <56100355+shljsl75891@users.noreply.github.com> Co-authored-by: supplefrog <78985073+supplefrog@users.noreply.github.com> Co-authored-by: KonTy <9524513+KonTy@users.noreply.github.com> --- Compile.ps1 | 5 +- README.md | 67 ++- config/applications.json | 32 +- config/themes.json | 42 ++ config/tweaks.json | 31 ++ .../private/Invoke-WinUtilCurrentSystem.ps1 | 8 +- functions/private/Invoke-WinUtilTweaks.ps1 | 29 +- functions/private/Set-WinUtilUiTheme.ps1 | 48 ++ functions/public/Invoke-WPFButton.ps1 | 1 + functions/public/Invoke-WPFFixesNetwork.ps1 | 11 + functions/public/Invoke-WPFPanelAutologin.ps1 | 2 +- scripts/main.ps1 | 10 + scripts/start.ps1 | 7 + winutil.ps1 | 441 +++++++++++++++--- xaml/inputXML.xaml | 218 +++++++-- 15 files changed, 808 insertions(+), 144 deletions(-) create mode 100644 config/themes.json create mode 100644 functions/private/Set-WinUtilUiTheme.ps1 create mode 100644 functions/public/Invoke-WPFFixesNetwork.ps1 diff --git a/Compile.ps1 b/Compile.ps1 index 38b32a9bc6..04c19e9d52 100644 --- a/Compile.ps1 +++ b/Compile.ps1 @@ -2,7 +2,10 @@ $OFS = "`r`n" $scriptname = "winutil.ps1" -Remove-Item .\$scriptname +if (Test-Path -Path "$($scriptname)") +{ + Remove-Item -Force "$($scriptname)" +} Write-output ' ################################################################################################################ diff --git a/README.md b/README.md index fb44a20708..24038794f9 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,13 @@ # Chris Titus Tech's Windows Utility -This Utility is a compilation of windows tasks I perform on each Windows system I use. It is meant to streamline *installs*, debloat with *tweaks*, troubleshoot with *config*, and fix Windows *updates*. I am extremely picky on any contributions to keep this project clean and efficient. +This Utility is a compilation of Windows tasks I perform on each Windows system I use. It is meant to streamline *installs*, debloat with *tweaks*, troubleshoot with *config*, and fix Windows *updates*. I am extremely picky about any contributions to keep this project clean and efficient. ![screen-install](screen-install.png) -Requires you to launch PowerShell or Windows Terminal As ADMINISTRATOR! +## Usage: -The recommended way is to right click on the start menu and select (PowerShell As Admin *Windows 10* - Windows Terminal As Admin *Windows 11*) +Requires you to launch PowerShell or Windows Terminal As **ADMINISTRATOR!** +The recommended way is to right-click on the start menu and select (PowerShell As Admin *Windows 10* - Windows Terminal As Admin *Windows 11*) Launch Command: @@ -21,6 +22,7 @@ If you are having TLS 1.2 Issues or You cannot find or resolve `christitus.com/w ``` [Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12;iex(New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/ChrisTitusTech/winutil/main/winutil.ps1') ``` + If you are still having issues try changing your DNS provider to 1.1.1.1 or 8.8.8.8 EXE Wrapper for $10 @ https://www.cttstore.com/windows-toolbox @@ -28,27 +30,60 @@ EXE Wrapper for $10 @ https://www.cttstore.com/windows-toolbox ## Overview - Install - - Installs all selected programs - - Has Upgrade ALL existing programs button + - Install Selection: Organize programs by category and facilitate installation by enabling users to select programs and initiate the installation process with a single click. + + - Upgrade All: Upgrade all existing programs to their latest versions, ensuring users have the most up-to-date and feature-rich software. + + - Uninstall Selection: Effortlessly uninstall selected programs, providing users with a streamlined way to remove unwanted software from their system. + + - Get Installed: Retrieve a comprehensive list of installed programs on the system, offering users visibility into the software currently installed on their computer. + + - Import / Export: Enable users to import or export the selection list of programs, allowing them to save their preferred program configurations or share them with others. This feature promotes convenience and flexibility in managing program selections across different systems. + - Tweaks - - Optimizes windows and reduces running processes - - Has recommended settings for each type of system + - Recommended Selection: Provides pre-defined templates tailored for desktop, laptop, and minimal configurations, allowing users to select recommended settings and optimizations specific to their system type. + + - Essential Tweaks: Offers a collection of essential tweaks aimed at improving system performance, privacy, and resource utilization. These tweaks include creating a system restore point, disabling telemetry, Wi-Fi Sense, setting services to manual, disabling location tracking, and HomeGroup, among others. + + - Misc. Tweaks: Encompasses a range of various tweaks to further optimize the system. These tweaks include enabling/disabling power throttling, enabling num lock on startup, removing Cortana and Edge, disabling User Account Control (UAC), notification panel, and configuring TPM during updates, among others. + + - Additional Tweaks: Introduces various other tweaks such as enabling dark mode, changing DNS settings, adding an Ultimate Performance mode, and creating shortcuts for WinUtil tools. These tweaks provide users with additional customization options to tailor their system to their preferences. + - Config - - Quick configurations for Windows Installs - - Has old legacy panels from Windows 7 - - Reset Windows Update to factory settings - - System Corruption Scan -- Updates - - Fixes the default windows update scheme + - Features: Allows users to easily install various essential components and features to enhance their Windows experience. These features include installing .NET Frameworks, enabling Hyper-V virtualization, enabling legacy media support for Windows Media Player and DirectPlay, enabling NFS (Network File System) for network file sharing, and enabling Windows Subsystem for Linux (WSL) for running Linux applications on Windows. + + - Fixes: Provides a range of helpful fixes to address common issues and improve system stability. This includes setting up autologon for seamless login experiences, resetting Windows updates to resolve update-related problems, performing a system corruption scan to detect and repair corrupted files, and resetting network settings to troubleshoot network connectivity issues. + + - Legacy Windows Panels: Includes access to legacy Windows panels from Windows 7, allowing users to access familiar and powerful tools. These panels include Control Panel for managing system settings, Network Connections for configuring network adapters and connections, Power Panel for adjusting power and sleep settings, Sound Settings for managing audio devices and settings, System Properties for viewing and modifying system information, and User Accounts for managing user profiles and account settings. + + +- Updates: + - Default (Out of Box) Settings: Provides the default settings that come with Windows for updates. + + - Security (Recommended) Settings: Offers recommended settings, including a slight delay of feature updates by 2 days and installation of security updates 4 days after release. + + - Disable All Updates (Not Recommended!): Allows users to disable all Windows updates, but it's not recommended due to potential security risks. + Video and Written Article walkthrough @ ## Issues -If you have any issues with the script please submit them to Issues tab here on GitHub and fill out the template so I can fix any bugs or make feature requests. +If you encounter any challenges or problems with the script, I kindly request that you submit them via the "Issues" tab on the GitHub repository. By filling out the provided template, you can provide specific details about the issue, allowing me to promptly address any bugs or consider feature requests. ## Contribute Code -**Any new code must be submitted to TEST BRANCH! - No merges will be performed on MAIN branch** +To contribute a new code, please ensure that it is submitted to the **TEST BRANCH**. Please note that merges will not be performed directly on the MAIN branch. + +When creating pull requests, it is essential to thoroughly document all changes made. This includes documenting any additions made to the tweaks section and ensuring that corresponding undo measures are in place to remove the newly added tweaks if necessary. Failure to adhere to this format may result in denial of the pull request. Additionally, comprehensive documentation is required for all code changes. Any code lacking sufficient documentation may also be denied. + +By following these guidelines, we can maintain a high standard of quality and ensure that the codebase remains organized and well-documented. + +## Thanks to all Contributors +Thanks a lot for spending your time helping Winutil grow. Thanks a lot! Keep rocking 🍻. + +[![Contributors](https://contrib.rocks/image?repo=ChrisTitusTech/winutil)](https://github.com/ChrisTitusTech/winutil/graphs/contributors) -For pull requests, be sure and document ALL changes. If you add something to the tweaks section the undo MUST also be applied to remove the new tweaks. Any tweak not following this format will be denied. Any code not well documented will be denied. +## Support +- This project needs a ⭐️ from you. Don't forget to leave a star ⭐️. +- EXE Wrapper for $10 @ https://www.cttstore.com/windows-toolbox diff --git a/config/applications.json b/config/applications.json index 0491a1b225..2d278bcdb2 100644 --- a/config/applications.json +++ b/config/applications.json @@ -91,6 +91,10 @@ "winget": "Git.Git;GitHub.GitHubDesktop", "choco": "git;github-desktop" }, + "WPFInstalldockerdesktop": { + "winget": "Docker.DockerDesktop", + "choco": "docker-desktop" + }, "WPFInstallgog": { "winget": "GOG.Galaxy", "choco": "goggalaxy" @@ -115,6 +119,10 @@ "winget": "REALiX.HWiNFO", "choco": "hwinfo" }, + "WPFInstallnomacs": { + "winget": "nomacs.nomacs", + "choco": "nomacs" + }, "WPFInstallimageglass": { "winget": "DuongDieuPhap.ImageGlass", "choco": "imageglass" @@ -348,11 +356,11 @@ "choco": "dotnet-6.0-runtime" }, "WPFInstallvc2015_64": { - "winget": "Microsoft.VC++2015-2022Redist-x64", + "winget": "Microsoft.VCRedist.2015+.x64", "choco": "na" }, "WPFInstallvc2015_32": { - "winget": "Microsoft.VC++2015-2022Redist-x86", + "winget": "Microsoft.VCRedist.2015+.x86", "choco": "na" }, "WPFInstallfoxpdf": { @@ -460,16 +468,16 @@ "choco": "telegram" }, "WPFInstallunity": { - "winget": "UnityTechnologies.UnityHub", + "winget": "Unity.UnityHub", "choco": "unityhub" }, "WPFInstallqbittorrent": { "winget": "qBittorrent.qBittorrent", "choco": "qbittorrent" }, - "WPFInstallorigin": { + "WPFInstalleaapp": { "winget": "ElectronicArts.EADesktop", - "choco": "origin" + "choco": "ea-app" }, "WPFInstallopenshell": { "winget": "Open-Shell.Open-Shell-Menu", @@ -516,7 +524,7 @@ "choco": "nuget.commandline" }, "WPFInstallwinrar": { - "winget": "RARLab.WinRar", + "winget": "RARLab.WinRAR", "choco": "winrar" }, "WPFInstallneovim": { @@ -530,5 +538,17 @@ "WPFInstallpostman": { "winget": "Postman.Postman", "choco": "postman" + }, + "WPFInstallgsudo": { + "winget": "gerardog.gsudo", + "choco": "gsudo" + }, + "WPFInstallwingetui": { + "winget": "SomePythonThings.WingetUIStore", + "choco": "na" + }, + "WPFInstallprismlauncher": { + "winget": "PrismLauncher.PrismLauncher", + "choco": "na" } } diff --git a/config/themes.json b/config/themes.json new file mode 100644 index 0000000000..a710b134fd --- /dev/null +++ b/config/themes.json @@ -0,0 +1,42 @@ +{ + "Classic": { + "ComboBoxBackgroundColor": "#777777", + "LabelboxForegroundColor": "#000000", + "MainForegroundColor": "#000000", + "MainBackgroundColor": "#777777", + "LabelBackgroundColor": "#777777", + "ComboBoxForegroundColor": "#000000", + "ButtonInstallBackgroundColor": "#222222", + "ButtonTweaksBackgroundColor": "#333333", + "ButtonConfigBackgroundColor": "#444444", + "ButtonUpdatesBackgroundColor": "#555555", + "ButtonInstallForegroundColor": "#FFFFFF", + "ButtonBackgroundColor": "#CACACA", + "ButtonBackgroundPressedColor": "#FFFFFF", + "ButtonBackgroundMouseoverColor": "AliceBlue", + "ButtonForegroundColor": "#000000", + "ButtonBorderThickness": "0", + "ButtonMargin": "0,3,0,3", + "ButtonCornerRadius": "0" + }, + "Matrix": { + "ComboBoxBackgroundColor": "#000000", + "LabelboxForegroundColor": "#FFEE58", + "MainForegroundColor": "#9CCC65", + "MainBackgroundColor": "#000000", + "LabelBackgroundColor": "#000000", + "ComboBoxForegroundColor": "#FFEE58", + "ButtonInstallBackgroundColor": "#222222", + "ButtonTweaksBackgroundColor": "#333333", + "ButtonConfigBackgroundColor": "#444444", + "ButtonUpdatesBackgroundColor": "#555555", + "ButtonInstallForegroundColor": "#FFFFFF", + "ButtonBackgroundColor": "#000000", + "ButtonBackgroundPressedColor": "#FFFFFF", + "ButtonBackgroundMouseoverColor": "#A55A64", + "ButtonForegroundColor": "#9CCC65", + "ButtonBorderThickness": "3", + "ButtonMargin": "2", + "ButtonCornerRadius": "4" + } +} diff --git a/config/tweaks.json b/config/tweaks.json index b279473da1..58defab3ac 100644 --- a/config/tweaks.json +++ b/config/tweaks.json @@ -1922,6 +1922,9 @@ ], "InvokeScript": [ "Set-ItemProperty -Path \"HKCU:\\Control Panel\\Desktop\" -Name \"UserPreferencesMask\" -Type Binary -Value ([byte[]](144,18,3,128,16,0,0,0))" + ], + "UndoScript": [ + "Remove-ItemProperty -Path \"HKCU:\\Control Panel\\Desktop\" -Name \"UserPreferencesMask\"" ] }, "WPFEssTweaksDeBloat": { @@ -2055,6 +2058,10 @@ "WPFEssTweaksStorage": { "InvokeScript": [ "Remove-Item -Path \"HKCU:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\StorageSense\\Parameters\\StoragePolicy\" -Recurse -ErrorAction SilentlyContinue" + ], + "UndoScript": [ + "New-Item -Path \"HKCU:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\StorageSense\\Parameters\\StoragePolicy\" | Out-Null + " ] }, "WPFMiscTweaksLapNum": { @@ -2136,6 +2143,9 @@ } } " + ], + "UndoScript": [ + "winget install Microsoft.Edge" ] }, "WPFMiscTweaksDisableNotifications": { @@ -2159,6 +2169,12 @@ "WPFMiscTweaksRightClickMenu": { "InvokeScript": [ "New-Item -Path \"HKCU:\\Software\\Classes\\CLSID\\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\" -Name \"InprocServer32\" -force -value \"\" " + ], + "UndoScript": [ + " + Remove-Item -Path \"HKCU:\\Software\\Classes\\CLSID\\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\" -Recurse -Confirm:$false -Force + Write-Host Restart Needed for change + " ] }, "WPFEssTweaksDiskCleanup": { @@ -2238,6 +2254,17 @@ } ] }, + "WPFMiscTweaksEnableVerboselogon": { + "registry": [ + { + "path": "HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\policies\\system", + "OriginalValue": "0", + "name": "VerboseStatus", + "value": "1", + "type": "DWord" + } + ] + }, "WPFEssTweaksDeleteTempFiles": { "InvokeScript": [ "Get-ChildItem -Path \"C:\\Windows\\Temp\" *.* -Recurse | Remove-Item -Force -Recurse @@ -2247,6 +2274,10 @@ "WPFEssTweaksRemoveCortana": { "InvokeScript": [ "Get-AppxPackage -allusers Microsoft.549981C3F5F10 | Remove-AppxPackage" + ], + "UndoScript": [ + "Get-AppxPackage -allusers | where Name -like \"Microsoft.549981C3F5F10\" | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register \"$($_.InstallLocation)\\AppXManifest.xml\"} + " ] }, "WPFEssTweaksDVR": { diff --git a/functions/private/Invoke-WinUtilCurrentSystem.ps1 b/functions/private/Invoke-WinUtilCurrentSystem.ps1 index 6612e56137..556288ce82 100644 --- a/functions/private/Invoke-WinUtilCurrentSystem.ps1 +++ b/functions/private/Invoke-WinUtilCurrentSystem.ps1 @@ -26,8 +26,12 @@ Function Invoke-WinUtilCurrentSystem { $filter = Get-WinUtilVariables -Type Checkbox | Where-Object {$psitem -like "WPFInstall*"} $sync.GetEnumerator() | Where-Object {$psitem.Key -in $filter} | ForEach-Object { - if($sync.configs.applications.$($psitem.Key).winget -in $sync.InstalledPrograms.Id){ - Write-Output $psitem.name + $dependencies = $($sync.configs.applications.$($psitem.Key).winget -split ";") + + Foreach ($dependency in $dependencies) { + if($dependency -in $sync.InstalledPrograms.Id){ + Write-Output $psitem.name + } } } } diff --git a/functions/private/Invoke-WinUtilTweaks.ps1 b/functions/private/Invoke-WinUtilTweaks.ps1 index 61f10e1031..a345b0a18f 100644 --- a/functions/private/Invoke-WinUtilTweaks.ps1 +++ b/functions/private/Invoke-WinUtilTweaks.ps1 @@ -15,19 +15,16 @@ function Invoke-WinUtilTweaks { Registry = "OriginalValue" ScheduledTask = "OriginalState" Service = "OriginalType" + ScriptType = "UndoScript" } + } Else{ $Values = @{ Registry = "Value" ScheduledTask = "State" Service = "StartupType" - } - } - - if($sync.configs.tweaks.$CheckBox.registry){ - $sync.configs.tweaks.$CheckBox.registry | ForEach-Object { - Set-WinUtilRegistry -Name $psitem.Name -Path $psitem.Path -Type $psitem.Type -Value $psitem.$($values.registry) + ScriptType = "InvokeScript" } } if($sync.configs.tweaks.$CheckBox.ScheduledTask){ @@ -40,6 +37,17 @@ function Invoke-WinUtilTweaks { Set-WinUtilService -Name $psitem.Name -StartupType $psitem.$($values.Service) } } + if($sync.configs.tweaks.$CheckBox.registry){ + $sync.configs.tweaks.$CheckBox.registry | ForEach-Object { + Set-WinUtilRegistry -Name $psitem.Name -Path $psitem.Path -Type $psitem.Type -Value $psitem.$($values.registry) + } + } + if($sync.configs.tweaks.$CheckBox.$($values.ScriptType)){ + $sync.configs.tweaks.$CheckBox.$($values.ScriptType) | ForEach-Object { + $Scriptblock = [scriptblock]::Create($psitem) + Invoke-WinUtilScript -ScriptBlock $scriptblock -Name $CheckBox + } + } if(!$undo){ if($sync.configs.tweaks.$CheckBox.appx){ @@ -47,11 +55,6 @@ function Invoke-WinUtilTweaks { Remove-WinUtilAPPX -Name $psitem } } - if($sync.configs.tweaks.$CheckBox.InvokeScript){ - $sync.configs.tweaks.$CheckBox.InvokeScript | ForEach-Object { - $Scriptblock = [scriptblock]::Create($psitem) - Invoke-WinUtilScript -ScriptBlock $scriptblock -Name $CheckBox - } - } + } -} +} \ No newline at end of file diff --git a/functions/private/Set-WinUtilUiTheme.ps1 b/functions/private/Set-WinUtilUiTheme.ps1 new file mode 100644 index 0000000000..5cd3eeb7b5 --- /dev/null +++ b/functions/private/Set-WinUtilUiTheme.ps1 @@ -0,0 +1,48 @@ +function Set-WinUtilUITheme { + <# + + .DESCRIPTION + This function will set theme to the XAML file + + .EXAMPLE + + Set-WinUtilUITheme -inputXAML $inputXAML + + #> + param + ( + [Parameter(Mandatory=$true, Position=0)] + [string] $inputXML, + [Parameter(Mandatory=$false, Position=1)] + [string] $themeName = 'matrix' + ) + + try { + # Convert the JSON to a PowerShell object + $themes = $sync.configs.themes + # Select the specified theme + $selectedTheme = $themes.$themeName + + if ($selectedTheme) { + # Loop through all key-value pairs in the selected theme + foreach ($property in $selectedTheme.PSObject.Properties) { + $key = $property.Name + $value = $property.Value + # Add curly braces around the key + $formattedKey = "{$key}" + # Replace the key with the value in the input XML + $inputXML = $inputXML.Replace($formattedKey, $value) + } + } + else { + Write-Host "Theme '$themeName' not found." + } + + } + catch { + Write-Warning "Unable to apply theme" + Write-Warning $psitem.Exception.StackTrace + } + + return $inputXML; +} diff --git a/functions/public/Invoke-WPFButton.ps1 b/functions/public/Invoke-WPFButton.ps1 index a140f99a04..536d9c3ae2 100644 --- a/functions/public/Invoke-WPFButton.ps1 +++ b/functions/public/Invoke-WPFButton.ps1 @@ -45,6 +45,7 @@ function Invoke-WPFButton { "WPFPaneluser" {Invoke-WPFControlPanel -Panel $button} "WPFUpdatesdefault" {Invoke-WPFUpdatesdefault} "WPFFixesUpdate" {Invoke-WPFFixesUpdate} + "WPFFixesNetwork" {Invoke-WPFFixesNetwork} "WPFUpdatesdisable" {Invoke-WPFUpdatesdisable} "WPFUpdatessecurity" {Invoke-WPFUpdatessecurity} "WPFWinUtilShortcut" {Invoke-WPFShortcut -ShortcutToAdd "WinUtil"} diff --git a/functions/public/Invoke-WPFFixesNetwork.ps1 b/functions/public/Invoke-WPFFixesNetwork.ps1 new file mode 100644 index 0000000000..980c67bf1d --- /dev/null +++ b/functions/public/Invoke-WPFFixesNetwork.ps1 @@ -0,0 +1,11 @@ +function Invoke-WPFFixesNetwork { + <# + + .DESCRIPTION + PlaceHolder + + #> + Write-Host "Reseting Network with netsh" + netsh int ip reset + netsh winsock reset +} \ No newline at end of file diff --git a/functions/public/Invoke-WPFPanelAutologin.ps1 b/functions/public/Invoke-WPFPanelAutologin.ps1 index a9aa2fcb44..1cd14ef98c 100644 --- a/functions/public/Invoke-WPFPanelAutologin.ps1 +++ b/functions/public/Invoke-WPFPanelAutologin.ps1 @@ -6,5 +6,5 @@ function Invoke-WPFPanelAutologin { #> curl.exe -ss "https://live.sysinternals.com/Autologon.exe" -o $env:temp\autologin.exe # Official Microsoft recommendation https://learn.microsoft.com/en-us/sysinternals/downloads/autologon - cmd /c $env:temp\autologin.exe + cmd /c $env:temp\autologin.exe /accepteula } \ No newline at end of file diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 3a1f867bf0..2027612f86 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -47,6 +47,16 @@ $sync.runspace.Open() #endregion exception classes $inputXML = $inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^ Start-Transcript $ENV:TEMP\Winutil.log -Append @@ -21,9 +21,16 @@ Add-Type -AssemblyName System.Windows.Forms # variable to sync between runspaces $sync = [Hashtable]::Synchronized(@{}) $sync.PSScriptRoot = $PSScriptRoot -$sync.version = "23.05.16" +$sync.version = "23.07.13" $sync.configs = @{} $sync.ProcessRunning = $false + + +if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { + Write-Output "Winutil needs to be ran as Administrator. Attempting to relaunch." + Start-Process -Verb runas -FilePath powershell.exe -ArgumentList "iwr -useb https://christitus.com/win | iex" + break +} Function Get-WinUtilCheckBoxes { <# @@ -360,8 +367,12 @@ Function Invoke-WinUtilCurrentSystem { $filter = Get-WinUtilVariables -Type Checkbox | Where-Object {$psitem -like "WPFInstall*"} $sync.GetEnumerator() | Where-Object {$psitem.Key -in $filter} | ForEach-Object { - if($sync.configs.applications.$($psitem.Key).winget -in $sync.InstalledPrograms.Id){ - Write-Output $psitem.name + $dependencies = $($sync.configs.applications.$($psitem.Key).winget -split ";") + + Foreach ($dependency in $dependencies) { + if($dependency -in $sync.InstalledPrograms.Id){ + Write-Output $psitem.name + } } } } @@ -546,19 +557,16 @@ function Invoke-WinUtilTweaks { Registry = "OriginalValue" ScheduledTask = "OriginalState" Service = "OriginalType" + ScriptType = "UndoScript" } + } Else{ $Values = @{ Registry = "Value" ScheduledTask = "State" Service = "StartupType" - } - } - - if($sync.configs.tweaks.$CheckBox.registry){ - $sync.configs.tweaks.$CheckBox.registry | ForEach-Object { - Set-WinUtilRegistry -Name $psitem.Name -Path $psitem.Path -Type $psitem.Type -Value $psitem.$($values.registry) + ScriptType = "InvokeScript" } } if($sync.configs.tweaks.$CheckBox.ScheduledTask){ @@ -571,6 +579,17 @@ function Invoke-WinUtilTweaks { Set-WinUtilService -Name $psitem.Name -StartupType $psitem.$($values.Service) } } + if($sync.configs.tweaks.$CheckBox.registry){ + $sync.configs.tweaks.$CheckBox.registry | ForEach-Object { + Set-WinUtilRegistry -Name $psitem.Name -Path $psitem.Path -Type $psitem.Type -Value $psitem.$($values.registry) + } + } + if($sync.configs.tweaks.$CheckBox.$($values.ScriptType)){ + $sync.configs.tweaks.$CheckBox.$($values.ScriptType) | ForEach-Object { + $Scriptblock = [scriptblock]::Create($psitem) + Invoke-WinUtilScript -ScriptBlock $scriptblock -Name $CheckBox + } + } if(!$undo){ if($sync.configs.tweaks.$CheckBox.appx){ @@ -578,12 +597,7 @@ function Invoke-WinUtilTweaks { Remove-WinUtilAPPX -Name $psitem } } - if($sync.configs.tweaks.$CheckBox.InvokeScript){ - $sync.configs.tweaks.$CheckBox.InvokeScript | ForEach-Object { - $Scriptblock = [scriptblock]::Create($psitem) - Invoke-WinUtilScript -ScriptBlock $scriptblock -Name $CheckBox - } - } + } } function Remove-WinUtilAPPX { @@ -775,6 +789,54 @@ Function Set-WinUtilService { Write-Warning $psitem.Exception.StackTrace } } +function Set-WinUtilUITheme { + <# + + .DESCRIPTION + This function will set theme to the XAML file + + .EXAMPLE + + Set-WinUtilUITheme -inputXAML $inputXAML + + #> + param + ( + [Parameter(Mandatory=$true, Position=0)] + [string] $inputXML, + [Parameter(Mandatory=$false, Position=1)] + [string] $themeName = 'matrix' + ) + + try { + # Convert the JSON to a PowerShell object + $themes = $sync.configs.themes + # Select the specified theme + $selectedTheme = $themes.$themeName + + if ($selectedTheme) { + # Loop through all key-value pairs in the selected theme + foreach ($property in $selectedTheme.PSObject.Properties) { + $key = $property.Name + $value = $property.Value + # Add curly braces around the key + $formattedKey = "{$key}" + # Replace the key with the value in the input XML + $inputXML = $inputXML.Replace($formattedKey, $value) + } + } + else { + Write-Host "Theme '$themeName' not found." + } + + } + catch { + Write-Warning "Unable to apply theme" + Write-Warning $psitem.Exception.StackTrace + } + + return $inputXML; +} function Test-WinUtilPackageManager { <# @@ -871,6 +933,7 @@ function Invoke-WPFButton { "WPFPaneluser" {Invoke-WPFControlPanel -Panel $button} "WPFUpdatesdefault" {Invoke-WPFUpdatesdefault} "WPFFixesUpdate" {Invoke-WPFFixesUpdate} + "WPFFixesNetwork" {Invoke-WPFFixesNetwork} "WPFUpdatesdisable" {Invoke-WPFUpdatesdisable} "WPFUpdatessecurity" {Invoke-WPFUpdatessecurity} "WPFWinUtilShortcut" {Invoke-WPFShortcut -ShortcutToAdd "WinUtil"} @@ -966,6 +1029,17 @@ function Invoke-WPFFeatureInstall { [System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon) } } +function Invoke-WPFFixesNetwork { + <# + + .DESCRIPTION + PlaceHolder + + #> + Write-Host "Reseting Network with netsh" + netsh int ip reset + netsh winsock reset +} function Invoke-WPFFixesUpdate { <# @@ -1287,7 +1361,7 @@ function Invoke-WPFPanelAutologin { #> curl.exe -ss "https://live.sysinternals.com/Autologon.exe" -o $env:temp\autologin.exe # Official Microsoft recommendation https://learn.microsoft.com/en-us/sysinternals/downloads/autologon - cmd /c $env:temp\autologin.exe + cmd /c $env:temp\autologin.exe /accepteula } function Invoke-WPFPanelDISM { <# @@ -1945,10 +2019,134 @@ $inputXML = ' + + + + + + - + - + @@ -2030,12 +2228,16 @@ $inputXML = ' - + -