From 075f2e9a50c08310aef45296bb42d85ea661680d Mon Sep 17 00:00:00 2001 From: Chris Titus Date: Tue, 9 May 2023 13:14:27 -0500 Subject: [PATCH] Test 03 2023 (#726) * Update inputXML.xaml * Compile Winutil * Update main.ps1 (#641) Fix DarkMode * Compile Winutil * Compile Winutil * Compile Winutil * Update tweaks.json * fix hovertime * shortcut (#643) add ability to create a shortcut to invoke winutil more easily * Compile Winutil * Tweaks Check (#646) * Tweaks Check Added check for no checked tweaks plus formatting * more formating fixing * Compile Winutil * [ooshutup10] Fixed link to ooshutup10 settings file (#665) * Compile Winutil * Features Migrated to config and runspaces (#667) * Compile Winutil * Document Calendar Disable/Enable Check Disable Notification and click undo tweaks to re-enable calendar * Compile Winutil * Update Edge_Removal.bat * Update Edge_Removal.bat (#660) * garbage commit - read system Trying to read current system registry values state and do a checkbox for enabled or disabled values * Compile Winutil * Add Ubisoft Connect & WinRAR as install options. (#678) * Compile Winutil * adding the code from asheroto to install winget (#684) * adding the code from asheroto to get winget with Server versions of Windows, that come without winget , the script seems unable to install it and then refuses to install any programs. so by adding two lines of code (hopefully) you can include the installation of winget and then fulfill the requirement and let the program run and do all the cool things * instaling winget from asheroto so the script will check if winget is installed on server and LTSC versions of Windows. and tries to install it, when for some reason it can't, then a condition on the code gets fulfilled and the function breaks, this code from the asheroto repo should, (hopefully) make it so winget can get installed and the condition is never met, therefore allowing it the script to continue * Compile Winutil * Add Neovim and Node Version Manager (#691) * Compile Winutil * Preload Winget and tweaks with already installed (#682) * winget * updated runspaces and winget to update gui outside of main thread * registry check for tweaks * add impex to winget * add uninstall button * tweaks done * update tests --------- Co-authored-by: Chris Titus * Compile Winutil * feat: add postman into developement (#695) Co-authored-by: Chris Titus * Update inputXML.xaml (#701) Some of the items were missing WPF in the name * Compile Winutil * Split up AllowGameDVR to fix breaking Xbox Game Bar (#692) * Split up AllowGameDVR to fix breaking Xbox Game Bar * Undo changes to winutil * Compile Winutil * Removed Atom due to it having been sunsetted (#711) Co-authored-by: Chris Titus * Add application GeForce NOW to Applications/Games (#724) * Compile Winutil * Fix syntax and typo * Compile Winutil * Fixing Original Service Types * Compile Winutil * Update inputXML.xaml (#725) Fix typo as upgrade selection will upgrade all * Compile Winutil --------- Co-authored-by: ChrisTitusTech Co-authored-by: DeveloperDurp Co-authored-by: jokerwrld999 <47574931+jokerwrld999@users.noreply.github.com> Co-authored-by: Raf <69535896+Rafee-M@users.noreply.github.com> Co-authored-by: Jack Boecker Co-authored-by: migno_chrono <75509204+mignochrono@users.noreply.github.com> Co-authored-by: Umair Raza <52033975+umairraza96@users.noreply.github.com> Co-authored-by: dreamsyntax Co-authored-by: Daniel <74148862+Danulal@users.noreply.github.com> Co-authored-by: tomgrice --- Edge_Removal.bat | 8 +- config/applications.json | 28 +- config/feature.json | 88 +- config/tweaks.json | 1271 ++++++++- functions/private/Get-WinUtilCheckBoxes.ps1 | 23 +- functions/private/Get-WinUtilRegistry.ps1 | 33 + functions/private/Get-WinUtilVariables.ps1 | 29 + .../private/Install-WinUtilProgramWinget.ps1 | 19 +- functions/private/Install-WinUtilWinget.ps1 | 8 + .../private/Invoke-WinUtilCurrentSystem.ps1 | 100 + .../private/Invoke-WinUtilFeatureInstall.ps1 | 53 + functions/public/Invoke-WPFButton.ps1 | 13 +- functions/public/Invoke-WPFFeatureInstall.ps1 | 73 +- functions/public/Invoke-WPFGetInstalled.ps1 | 46 + functions/public/Invoke-WPFImpex.ps1 | 9 +- functions/public/Invoke-WPFPresets.ps1 | 26 +- functions/public/Invoke-WPFRunspace.ps1 | 33 +- functions/public/Invoke-WPFShortcut.ps1 | 33 + functions/public/Invoke-WPFTab.ps1 | 8 +- functions/public/Invoke-WPFUnInstall.ps1 | 58 + functions/public/Invoke-WPFtweaksbutton.ps1 | 20 +- functions/public/Invoke-WPFundoall.ps1 | 24 +- .../{runspace.Tests.ps1 => configs.Tests.ps1} | 36 +- pester/functions.Tests.ps1 | 28 + pester/winutil.Tests.ps1 | 193 +- scripts/main.ps1 | 61 +- winutil.ps1 | 2479 +++++++++++++---- xaml/inputXML.xaml | 419 +-- 28 files changed, 3966 insertions(+), 1253 deletions(-) create mode 100644 functions/private/Get-WinUtilRegistry.ps1 create mode 100644 functions/private/Get-WinUtilVariables.ps1 create mode 100644 functions/private/Invoke-WinUtilCurrentSystem.ps1 create mode 100644 functions/private/Invoke-WinUtilFeatureInstall.ps1 create mode 100644 functions/public/Invoke-WPFGetInstalled.ps1 create mode 100644 functions/public/Invoke-WPFShortcut.ps1 create mode 100644 functions/public/Invoke-WPFUnInstall.ps1 rename pester/{runspace.Tests.ps1 => configs.Tests.ps1} (75%) create mode 100644 pester/functions.Tests.ps1 diff --git a/Edge_Removal.bat b/Edge_Removal.bat index de49e368..3821921b 100644 --- a/Edge_Removal.bat +++ b/Edge_Removal.bat @@ -1,10 +1,12 @@ +REM https://github.com/AveYo/fox/blob/main/Edge_Removal.bat is source file + @(set "0=%~f0"^)#) & powershell -nop -c iex([io.file]::ReadAllText($env:0)) & exit /b #:: double-click to run or just copy-paste into powershell - it's a standalone hybrid script sp 'HKCU:\Volatile Environment' 'Edge_Removal' @' $also_remove_webview = 1 -$host.ui.RawUI.WindowTitle = 'Edge Removal ' +$host.ui.RawUI.WindowTitle = 'Edge Removal - AveYo, 2022.10.03' ## targets $remove_win32 = @("Microsoft Edge","Microsoft Edge Update"); $remove_appx = @("MicrosoftEdge") if ($also_remove_webview -eq 1) {$remove_win32 += "Microsoft EdgeWebView"; $remove_appx += "Win32WebViewHost"} @@ -92,7 +94,7 @@ cmd /c "reg add ""$IFEO\msedge.exe\0"" /f /v FilterFullPath /d ""$MSEP\msedge.ex cmd /c "reg add ""$IFEO\msedge.exe\0"" /f /v Debugger /d ""$CMD $DIR\OpenWebSearch.cmd"" >nul" $OpenWebSearch = @$ -@title OpenWebSearch Redux & echo off & set ?= open start menu web search, widgets links or help in your chosen browser +@title OpenWebSearch Redux & echo off & set ?= open start menu web search, widgets links or help in your chosen browser - by AveYo for /f %%E in ('"prompt $E$S& for %%e in (1) do rem"') do echo;%%E[2t 2>nul & rem AveYo: minimize prompt call :reg_var "HKCU\SOFTWARE\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice" ProgID ProgID if /i "%ProgID%" equ "MSEdgeHTM" echo;Default browser is set to Edge! Change it or remove OpenWebSearch script. & pause & exit /b @@ -152,4 +154,4 @@ exit $A = '-nop -noe -c & {iex((gp ''Registry::HKEY_Users\S-1-5-21*\Volatile*'' Edge_Removal -ea 0)[0].Edge_Removal)}' start powershell -args $A -verb runas $_Press_Enter -#:: \ No newline at end of file +#:: diff --git a/config/applications.json b/config/applications.json index dde19552..edb28521 100644 --- a/config/applications.json +++ b/config/applications.json @@ -11,10 +11,6 @@ "winget": "AnyDeskSoftwareGmbH.AnyDesk", "choco": "anydesk" }, - "WPFInstallatom": { - "winget": "GitHub.Atom", - "choco": "atom" - }, "WPFInstallaudacity": { "winget": "Audacity.Audacity", "choco": "audacity" @@ -83,6 +79,10 @@ "winget": "PeterPawlowski.foobar2000", "choco": "foobar2000" }, + "WPFInstallgeforcenow": { + "winget": "Nvidia.GeForceNow", + "choco": "nvidia-geforce-now" + }, "WPFInstallgimp": { "winget": "GIMP.GIMP", "choco": "gimp" @@ -507,8 +507,28 @@ "winget": "Microsoft.Edge", "choco": "microsoft-edge" }, + "WPFInstallubisoft": { + "winget": "Ubisoft.Connect", + "choco": "ubisoft-connect" + }, "WPFInstallnuget": { "winget": "Microsoft.NuGet", "choco": "nuget.commandline" + }, + "WPFInstallwinrar": { + "winget": "RARLab.WinRar", + "choco": "winrar" + }, + "WPFInstallneovim": { + "winget": "Neovim.Neovim", + "choco": "neovim" + }, + "WPFInstallnvm": { + "winget": "CoreyButler.NVMforWindows", + "choco": "nvm" + }, + "WPFInstallpostman": { + "winget": "Postman.Postman", + "choco": "postman" } } diff --git a/config/feature.json b/config/feature.json index 113f231e..3707c66e 100644 --- a/config/feature.json +++ b/config/feature.json @@ -1,31 +1,61 @@ { - "Featuresdotnet": [ - "NetFx4-AdvSrvs", - "NetFx3" - ], - "Featureshyperv": [ - "HypervisorPlatform", - "Microsoft-Hyper-V-All", - "Microsoft-Hyper-V", - "Microsoft-Hyper-V-Tools-All", - "Microsoft-Hyper-V-Management-PowerShell", - "Microsoft-Hyper-V-Hypervisor", - "Microsoft-Hyper-V-Services", - "Microsoft-Hyper-V-Management-Clients" - ], - "Featureslegacymedia": [ - "WindowsMediaPlayer", - "MediaPlayback", - "DirectPlay", - "LegacyComponents" - ], - "Featurewsl": [ - "VirtualMachinePlatform", - "Microsoft-Windows-Subsystem-Linux" - ], - "Featurenfs": [ - "ServicesForNFS-ClientOnly", - "ClientForNFS-Infrastructure", - "NFS-Administration" - ] + "WPFFeaturesdotnet": { + "feature": [ + "NetFx4-AdvSrvs", + "NetFx3" + ], + "InvokeScript": [ + + ] + }, + "WPFFeatureshyperv": { + "feature": [ + "HypervisorPlatform", + "Microsoft-Hyper-V-All", + "Microsoft-Hyper-V", + "Microsoft-Hyper-V-Tools-All", + "Microsoft-Hyper-V-Management-PowerShell", + "Microsoft-Hyper-V-Hypervisor", + "Microsoft-Hyper-V-Services", + "Microsoft-Hyper-V-Management-Clients" + ], + "InvokeScript": [ + "Start-Process -FilePath cmd.exe -ArgumentList '/c bcdedit /set hypervisorschedulertype classic' -Wait" + ] + }, + "WPFFeatureslegacymedia": { + "feature": [ + "WindowsMediaPlayer", + "MediaPlayback", + "DirectPlay", + "LegacyComponents" + ], + "InvokeScript": [ + + ] + }, + "WPFFeaturewsl": { + "feature": [ + "VirtualMachinePlatform", + "Microsoft-Windows-Subsystem-Linux" + ], + "InvokeScript": [ + + ] + }, + "WPFFeaturenfs": { + "feature": [ + "ServicesForNFS-ClientOnly", + "ClientForNFS-Infrastructure", + "NFS-Administration" + ], + "InvokeScript": [ + "nfsadmin client stop + Set-ItemProperty -Path 'HKLM:\\SOFTWARE\\Microsoft\\ClientForNFS\\CurrentVersion\\Default' -Name 'AnonymousUID' -Type DWord -Value 0 + Set-ItemProperty -Path 'HKLM:\\SOFTWARE\\Microsoft\\ClientForNFS\\CurrentVersion\\Default' -Name 'AnonymousGID' -Type DWord -Value 0 + nfsadmin client start + nfsadmin client localhost config fileaccess=755 SecFlavors=+sys -krb5 -krb5i + " + ] + } } diff --git a/config/tweaks.json b/config/tweaks.json index fba5e2f8..9f746f50 100644 --- a/config/tweaks.json +++ b/config/tweaks.json @@ -91,344 +91,1317 @@ "WPFEssTweaksServices": { "service": [ { + "Name": "AJRouter", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "diagnosticshub.standardcollector.service" + "OriginalType": "Manual" }, { + "Name": "ALG", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "DiagTrack" + "OriginalType": "Manual" }, { + "Name": "AppIDSvc", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "DPS" + "OriginalType": "Manual" }, { + "Name": "AppMgmt", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "dmwappushservice" + "OriginalType": "Manual" }, { + "Name": "AppReadiness", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "lfsvc" + "OriginalType": "Manual" }, { + "Name": "AppVClient", + "OriginalType": "Disabled" + }, + { + "Name": "AppXSvc", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "Appinfo", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "AssignedAccessManagerSvc", + "OriginalType": "Manual" + }, + { + "Name": "AudioEndpointBuilder", + "StartupType": "Automatic", + "OriginalType": "Automatic" + }, + { + "Name": "AudioSrv", + "StartupType": "Automatic" + }, + { + "Name": "Audiosrv", + "OriginalType": "Automatic" + }, + { + "Name": "AxInstSV", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "BDESVC", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "BFE", + "StartupType": "Automatic", + "OriginalType": "Automatic" + }, + { + "Name": "BITS", + "StartupType": "AutomaticDelayedStart", + "OriginalType": "Automatic" + }, + { + "Name": "BTAGService", + "OriginalType": "Manual" + }, + { + "Name": "BcastDVRUserService_dc2a4", + "OriginalType": "Manual" + }, + { + "Name": "BluetoothUserService_dc2a4", + "OriginalType": "Manual" + }, + { + "Name": "BrokerInfrastructure", + "StartupType": "Automatic", + "OriginalType": "Automatic" + }, + { + "Name": "Browser", + "StartupType": "Manual" + }, + { + "Name": "BthAvctpSvc", + "OriginalType": "Manual" + }, + { + "Name": "BthHFSrv", + "StartupType": "Manual" + }, + { + "Name": "CDPSvc", + "StartupType": "Manual", + "OriginalType": "Automatic" + }, + { + "Name": "CDPUserSvc_dc2a4", + "OriginalType": "Automatic" + }, + { + "Name": "COMSysApp", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "CaptureService_dc2a4", + "OriginalType": "Manual" + }, + { + "Name": "CertPropSvc", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "ClipSVC", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "ConsentUxUserSvc_dc2a4", + "OriginalType": "Manual" + }, + { + "Name": "CoreMessagingRegistrar", + "StartupType": "Automatic", + "OriginalType": "Automatic" + }, + { + "Name": "CredentialEnrollmentManagerUserSvc_dc2a4", + "OriginalType": "Manual" + }, + { + "Name": "CryptSvc", + "StartupType": "Automatic", + "OriginalType": "Automatic" + }, + { + "Name": "CscService", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "DPS", + "StartupType": "Automatic", + "OriginalType": "Automatic" + }, + { + "Name": "DcomLaunch", + "StartupType": "Automatic", + "OriginalType": "Automatic" + }, + { + "Name": "DcpSvc", + "StartupType": "Manual" + }, + { + "Name": "DevQueryBroker", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "DeviceAssociationBrokerSvc_dc2a4", + "OriginalType": "Manual" + }, + { + "Name": "DeviceAssociationService", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "DeviceInstall", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "DevicePickerUserSvc_dc2a4", + "OriginalType": "Manual" + }, + { + "Name": "DevicesFlowUserSvc_dc2a4", + "OriginalType": "Manual" + }, + { + "Name": "Dhcp", + "StartupType": "Automatic", + "OriginalType": "Automatic" + }, + { + "Name": "DiagTrack", + "StartupType": "Disabled", + "OriginalType": "Automatic" + }, + { + "Name": "DialogBlockingService", + "OriginalType": "Disabled" + }, + { + "Name": "DispBrokerDesktopSvc", + "OriginalType": "Automatic" + }, + { + "Name": "DisplayEnhancementService", + "OriginalType": "Manual" + }, + { + "Name": "DmEnrollmentSvc", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "Dnscache", + "StartupType": "Automatic", + "OriginalType": "Automatic" + }, + { + "Name": "DoSvc", + "StartupType": "AutomaticDelayedStart", + "OriginalType": "Automatic" + }, + { + "Name": "DsSvc", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "DsmSvc", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "DusmSvc", + "OriginalType": "Automatic" + }, + { + "Name": "EFS", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "EapHost", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "EntAppSvc", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "EventLog", + "StartupType": "Automatic", + "OriginalType": "Automatic" + }, + { + "Name": "EventSystem", + "StartupType": "Automatic", + "OriginalType": "Automatic" + }, + { + "Name": "FDResPub", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "Fax", + "StartupType": "Manual" + }, + { + "Name": "FontCache", + "StartupType": "Automatic", + "OriginalType": "Automatic" + }, + { + "Name": "FrameServer", + "OriginalType": "Manual" + }, + { + "Name": "FrameServerMonitor", + "OriginalType": "Manual" + }, + { + "Name": "GraphicsPerfSvc", + "OriginalType": "Manual" + }, + { + "Name": "HomeGroupListener", + "StartupType": "Manual" + }, + { + "Name": "HomeGroupProvider", + "StartupType": "Manual" + }, + { + "Name": "HvHost", + "OriginalType": "Manual" + }, + { + "Name": "IEEtwCollectorService", + "StartupType": "Manual" + }, + { + "Name": "IKEEXT", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "InstallService", + "OriginalType": "Manual" + }, + { + "Name": "InventorySvc", + "OriginalType": "Manual" + }, + { + "Name": "IpxlatCfgSvc", + "OriginalType": "Manual" + }, + { + "Name": "KeyIso", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "KtmRm", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "LSM", + "StartupType": "Automatic", + "OriginalType": "Automatic" + }, + { + "Name": "LanmanServer", + "StartupType": "Automatic", + "OriginalType": "Automatic" + }, + { + "Name": "LanmanWorkstation", + "StartupType": "Automatic", + "OriginalType": "Automatic" + }, + { + "Name": "LicenseManager", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "LxpSvc", + "OriginalType": "Manual" + }, + { + "Name": "MSDTC", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "MSiSCSI", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "MapsBroker", + "StartupType": "AutomaticDelayedStart", + "OriginalType": "Automatic" + }, + { + "Name": "McpManagementService", + "OriginalType": "Manual" + }, + { + "Name": "MessagingService_dc2a4", + "OriginalType": "Manual" + }, + { + "Name": "MicrosoftEdgeElevationService", + "OriginalType": "Manual" + }, + { + "Name": "MixedRealityOpenXRSvc", + "OriginalType": "Manual" + }, + { + "Name": "MpsSvc", + "StartupType": "Automatic" + }, + { + "Name": "MsKeyboardFilter", + "OriginalType": "Disabled" + }, + { + "Name": "NPSMSvc_dc2a4", + "OriginalType": "Manual" + }, + { + "Name": "NaturalAuthentication", + "OriginalType": "Manual" + }, + { + "Name": "NcaSvc", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "NcbService", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "NcdAutoSetup", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "NetSetupSvc", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "NetTcpPortSharing", + "StartupType": "Disabled", + "OriginalType": "Disabled" + }, + { + "Name": "Netlogon", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "Netman", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "NgcCtnrSvc", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "NgcSvc", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "NlaSvc", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "OneSyncSvc_dc2a4", + "OriginalType": "Automatic" + }, + { + "Name": "P9RdrService_dc2a4", + "OriginalType": "Manual" + }, + { + "Name": "PNRPAutoReg", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "PNRPsvc", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "PcaSvc", + "StartupType": "Manual", + "OriginalType": "Automatic" + }, + { + "Name": "PeerDistSvc", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "PenService_dc2a4", + "OriginalType": "Manual" + }, + { + "Name": "PerfHost", + "OriginalType": "Manual" + }, + { + "Name": "PhoneSvc", + "OriginalType": "Manual" + }, + { + "Name": "PimIndexMaintenanceSvc_dc2a4", + "OriginalType": "Manual" + }, + { + "Name": "PlugPlay", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "MapsBroker" + "OriginalType": "Manual" }, { + "Name": "PolicyAgent", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "NetTcpPortSharing" + "OriginalType": "Manual" + }, + { + "Name": "Power", + "StartupType": "Automatic", + "OriginalType": "Automatic" }, { + "Name": "PrintNotify", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "RemoteAccess" + "OriginalType": "Manual" + }, + { + "Name": "PrintWorkflowUserSvc_dc2a4", + "OriginalType": "Manual" + }, + { + "Name": "ProfSvc", + "StartupType": "Automatic", + "OriginalType": "Automatic" + }, + { + "Name": "PushToInstall", + "OriginalType": "Manual" }, { + "Name": "QWAVE", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "RemoteRegistry" + "OriginalType": "Manual" }, { + "Name": "RasAuto", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "SharedAccess" + "OriginalType": "Manual" }, { + "Name": "RasMan", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "TrkWks" + "OriginalType": "Manual" + }, + { + "Name": "RemoteAccess", + "StartupType": "Disabled", + "OriginalType": "Disabled" + }, + { + "Name": "RemoteRegistry", + "StartupType": "Disabled", + "OriginalType": "Disabled" }, { + "Name": "RetailDemo", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "WMPNetworkSvc" + "OriginalType": "Manual" }, { + "Name": "RmSvc", + "OriginalType": "Manual" + }, + { + "Name": "RpcEptMapper", + "StartupType": "Automatic", + "OriginalType": "Automatic" + }, + { + "Name": "RpcLocator", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "WSearch" + "OriginalType": "Manual" + }, + { + "Name": "RpcSs", + "StartupType": "Automatic", + "OriginalType": "Automatic" }, { + "Name": "SCPolicySvc", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "XblAuthManager" + "OriginalType": "Manual" + }, + { + "Name": "SCardSvr", + "StartupType": "Disabled", + "OriginalType": "Manual" }, { + "Name": "SDRSVC", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "XblGameSave" + "OriginalType": "Manual" + }, + { + "Name": "SEMgrSvc", + "OriginalType": "Manual" + }, + { + "Name": "SENS", + "StartupType": "Automatic", + "OriginalType": "Automatic" + }, + { + "Name": "SNMPTRAP", + "StartupType": "Manual" + }, + { + "Name": "SNMPTrap", + "OriginalType": "Manual" }, { + "Name": "SSDPSRV", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "XboxNetApiSvc" + "OriginalType": "Manual" }, { + "Name": "SamSs", + "StartupType": "Automatic", + "OriginalType": "Automatic" + }, + { + "Name": "ScDeviceEnum", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "XboxGipSvc" + "OriginalType": "Manual" + }, + { + "Name": "Schedule", + "StartupType": "Automatic", + "OriginalType": "Automatic" + }, + { + "Name": "SecurityHealthService", + "OriginalType": "Manual" + }, + { + "Name": "Sense", + "OriginalType": "Manual" }, { + "Name": "SensorDataService", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "ndu" + "OriginalType": "Manual" }, { + "Name": "SensorService", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "WerSvc" + "OriginalType": "Manual" }, { + "Name": "SensrSvc", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "Fax" + "OriginalType": "Manual" }, { + "Name": "SessionEnv", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "fhsvc" + "OriginalType": "Manual" }, { + "Name": "SgrmBroker", + "OriginalType": "Automatic" + }, + { + "Name": "SharedAccess", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "gupdate" + "OriginalType": "Manual" + }, + { + "Name": "SharedRealitySvc", + "OriginalType": "Manual" }, { + "Name": "ShellHWDetection", + "StartupType": "Automatic", + "OriginalType": "Automatic" + }, + { + "Name": "SmsRouter", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "gupdatem" + "OriginalType": "Manual" + }, + { + "Name": "Spooler", + "StartupType": "Automatic", + "OriginalType": "Automatic" }, { + "Name": "SstpSvc", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "stisvc" + "OriginalType": "Manual" }, { + "Name": "StateRepository", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "AJRouter" + "OriginalType": "Automatic" }, { + "Name": "StiSvc", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "MSDTC" + "OriginalType": "Manual" }, { + "Name": "StorSvc", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "WpcMonSvc" + "OriginalType": "Automatic" }, { + "Name": "SysMain", + "StartupType": "Automatic", + "OriginalType": "Automatic" + }, + { + "Name": "SystemEventsBroker", + "StartupType": "Automatic", + "OriginalType": "Automatic" + }, + { + "Name": "TabletInputService", + "StartupType": "Manual" + }, + { + "Name": "TapiSrv", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "PhoneSvc" + "OriginalType": "Manual" }, { + "Name": "TermService", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "PrintNotify" + "OriginalType": "Manual" + }, + { + "Name": "TextInputManagementService", + "OriginalType": "Automatic" + }, + { + "Name": "Themes", + "StartupType": "Automatic", + "OriginalType": "Automatic" + }, + { + "Name": "TieringEngineService", + "OriginalType": "Manual" + }, + { + "Name": "TimeBroker", + "StartupType": "Manual" + }, + { + "Name": "TimeBrokerSvc", + "OriginalType": "Manual" + }, + { + "Name": "TokenBroker", + "OriginalType": "Manual" + }, + { + "Name": "TrkWks", + "StartupType": "Automatic", + "OriginalType": "Automatic" + }, + { + "Name": "TroubleshootingSvc", + "OriginalType": "Manual" }, { + "Name": "TrustedInstaller", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "PcaSvc" + "OriginalType": "Manual" + }, + { + "Name": "UI0Detect", + "StartupType": "Manual" + }, + { + "Name": "UdkUserSvc_dc2a4", + "OriginalType": "Manual" + }, + { + "Name": "UevAgentService", + "OriginalType": "Disabled" }, { + "Name": "UmRdpService", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "WPDBusEnum" + "OriginalType": "Manual" + }, + { + "Name": "UnistoreSvc_dc2a4", + "OriginalType": "Manual" }, { + "Name": "UserDataSvc_dc2a4", + "OriginalType": "Manual" + }, + { + "Name": "UserManager", + "StartupType": "Automatic", + "OriginalType": "Automatic" + }, + { + "Name": "UsoSvc", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "seclogon" + "OriginalType": "Automatic" + }, + { + "Name": "VGAuthService", + "OriginalType": "Automatic" + }, + { + "Name": "VMTools", + "OriginalType": "Automatic" }, { + "Name": "VSS", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "SysMain" + "OriginalType": "Manual" }, { + "Name": "VacSvc", + "OriginalType": "Manual" + }, + { + "Name": "VaultSvc", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "lmhosts" + "OriginalType": "Manual" }, { + "Name": "W32Time", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "wisvc" + "OriginalType": "Manual" }, { + "Name": "WEPHOSTSVC", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "FontCache" + "OriginalType": "Manual" + }, + { + "Name": "WFDSConMgrSvc", + "OriginalType": "Manual" }, { + "Name": "WMPNetworkSvc", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "RetailDemo" + "OriginalType": "Manual" }, { + "Name": "WManSvc", + "OriginalType": "Manual" + }, + { + "Name": "WPDBusEnum", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "ALG" + "OriginalType": "Manual" + }, + { + "Name": "WSService", + "StartupType": "Manual" }, { + "Name": "WSearch", + "StartupType": "AutomaticDelayedStart", + "OriginalType": "Automatic" + }, + { + "Name": "WaaSMedicSvc", + "OriginalType": "Manual" + }, + { + "Name": "WalletService", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "SCardSvr" + "OriginalType": "Manual" }, { + "Name": "WarpJITSvc", + "OriginalType": "Manual" + }, + { + "Name": "WbioSrvc", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "EntAppSvc" + "OriginalType": "Manual" + }, + { + "Name": "Wcmsvc", + "StartupType": "Automatic", + "OriginalType": "Automatic" }, { + "Name": "WcsPlugInService", + "StartupType": "Manual" + }, + { + "Name": "WdNisSvc", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "BthAvctpSvc" + "OriginalType": "Manual" }, { + "Name": "WdiServiceHost", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "Browser" + "OriginalType": "Manual" }, { + "Name": "WdiSystemHost", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "BthAvctpSvc" + "OriginalType": "Manual" }, { + "Name": "WebClient", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "iphlpsvc" + "OriginalType": "Manual" }, { + "Name": "Wecsvc", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "edgeupdate" + "OriginalType": "Manual" }, { + "Name": "WerSvc", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "MicrosoftEdgeElevationService" + "OriginalType": "Manual" }, { + "Name": "WiaRpc", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "edgeupdatem" + "OriginalType": "Manual" + }, + { + "Name": "WinDefend", + "StartupType": "Automatic", + "OriginalType": "Automatic" }, { + "Name": "WinHttpAutoProxySvc", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "SEMgrSvc" + "OriginalType": "Manual" }, { + "Name": "WinRM", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "PerfHost" + "OriginalType": "Manual" + }, + { + "Name": "Winmgmt", + "StartupType": "Disabled", + "OriginalType": "Automatic" + }, + { + "Name": "WlanSvc", + "OriginalType": "Manual" }, { + "Name": "Wlansvc", + "StartupType": "Manual" + }, + { + "Name": "WpcMonSvc", + "OriginalType": "Manual" + }, + { + "Name": "WpnService", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "BcastDVRUserService_48486de" + "OriginalType": "Automatic" }, { + "Name": "WpnUserService_dc2a4", + "OriginalType": "Automatic" + }, + { + "Name": "WwanSvc", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "CaptureService_48486de" + "OriginalType": "Manual" }, { + "Name": "XblAuthManager", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "cbdhsvc_48486de" + "OriginalType": "Manual" }, { + "Name": "XblGameSave", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "WpnService" + "OriginalType": "Manual" + }, + { + "Name": "XboxGipSvc", + "OriginalType": "Manual" }, { + "Name": "XboxNetApiSvc", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "RtkBtManServ" + "OriginalType": "Manual" }, { + "Name": "autotimesvc", + "OriginalType": "Manual" + }, + { + "Name": "bthserv", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "QWAVE" + "OriginalType": "Manual" + }, + { + "Name": "camsvc", + "OriginalType": "Manual" }, { + "Name": "cbdhsvc_dc2a4", + "OriginalType": "Automatic" + }, + { + "Name": "cloudidsvc", + "OriginalType": "Manual" + }, + { + "Name": "dcsvc", + "OriginalType": "Manual" + }, + { + "Name": "defragsvc", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "diagnosticshub.standardcollector.service", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "diagsvc", + "OriginalType": "Manual" + }, + { + "Name": "dmwappushservice", + "StartupType": "Disabled", + "OriginalType": "Manual" + }, + { + "Name": "dot3svc", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "edgeupdate", + "OriginalType": "Automatic" + }, + { + "Name": "edgeupdatem", + "OriginalType": "Manual" + }, + { + "Name": "embeddedmode", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "fdPHost", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "fhsvc", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "gpsvc", + "StartupType": "Automatic", + "OriginalType": "Automatic" + }, + { + "Name": "hidserv", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "HPAppHelperCap" + "OriginalType": "Manual" }, { + "Name": "icssvc", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "HPDiagsCap" + "OriginalType": "Manual" }, { + "Name": "iphlpsvc", + "StartupType": "Automatic", + "OriginalType": "Automatic" + }, + { + "Name": "lfsvc", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "lltdsvc", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "HPNetworkCap" + "OriginalType": "Manual" }, { + "Name": "lmhosts", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "HPSysInfoCap" + "OriginalType": "Manual" + }, + { + "Name": "mpssvc", + "OriginalType": "Automatic" }, { + "Name": "msiserver", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "HpTouchpointAnalyticsService" + "OriginalType": "Manual" }, { + "Name": "netprofm", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "HvHost" + "OriginalType": "Manual" + }, + { + "Name": "nsi", + "StartupType": "Automatic", + "OriginalType": "Automatic" }, { + "Name": "p2pimsvc", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "vmickvpexchange" + "OriginalType": "Manual" }, { + "Name": "p2psvc", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "vmicguestinterface" + "OriginalType": "Manual" + }, + { + "Name": "perceptionsimulation", + "OriginalType": "Manual" }, { + "Name": "pla", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "vmicshutdown" + "OriginalType": "Manual" }, { + "Name": "seclogon", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "vmicheartbeat" + "OriginalType": "Manual" + }, + { + "Name": "shpamsvc", + "OriginalType": "Disabled" }, { + "Name": "smphost", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "vmicvmsession" + "OriginalType": "Manual" + }, + { + "Name": "spectrum", + "OriginalType": "Manual" + }, + { + "Name": "sppsvc", + "StartupType": "AutomaticDelayedStart", + "OriginalType": "Automatic" + }, + { + "Name": "ssh-agent", + "OriginalType": "Disabled" + }, + { + "Name": "svsvc", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "swprv", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "tiledatamodelsvc", + "StartupType": "Automatic" + }, + { + "Name": "tzautoupdate", + "OriginalType": "Disabled" + }, + { + "Name": "uhssvc", + "OriginalType": "Disabled" }, { + "Name": "upnphost", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "vmicrdv" + "OriginalType": "Manual" }, { + "Name": "vds", "StartupType": "Manual", - "OriginalType": "Automatic", - "Name": "vmictimesync" + "OriginalType": "Manual" + }, + { + "Name": "vm3dservice", + "OriginalType": "Automatic" + }, + { + "Name": "vmicguestinterface", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "vmicheartbeat", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "vmickvpexchange", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "vmicrdv", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "vmicshutdown", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "vmictimesync", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "vmicvmsession", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "vmicvss", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "vmvss", + "OriginalType": "Manual" + }, + { + "Name": "wbengine", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "wcncsvc", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "webthreatdefsvc", + "OriginalType": "Manual" + }, + { + "Name": "webthreatdefusersvc_dc2a4", + "OriginalType": "Automatic" + }, + { + "Name": "wercplsupport", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "wisvc", + "OriginalType": "Manual" + }, + { + "Name": "wlidsvc", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "wlpasvc", + "OriginalType": "Manual" + }, + { + "Name": "wmiApSrv", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "workfolderssvc", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "wscsvc", + "StartupType": "AutomaticDelayedStart", + "OriginalType": "Automatic" + }, + { + "Name": "wuauserv", + "StartupType": "Manual", + "OriginalType": "Manual" + }, + { + "Name": "wudfsvc", + "StartupType": "Manual" } ] }, @@ -657,10 +1630,11 @@ "type": "Dword" }, { + "_Comment" : "Driver searching is a function that should be left in", "Path": "HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\DriverSearching", "OriginalValue": "1", "name": "SearchOrderConfig", - "value": "0", + "value": "1", "type": "Dword" }, { @@ -702,21 +1676,21 @@ "Path": "HKLM:\\SYSTEM\\ControlSet001\\Services\\Ndu", "OriginalValue": "1", "name": "Start", - "value": "00000004", + "value": "4", "type": "Dword" }, { "Path": "HKCU:\\Control Panel\\Mouse", - "OriginalValue": "1", + "OriginalValue": "400", "name": "MouseHoverTime", "value": "400", "type": "String" }, { "Path": "HKLM:\\SYSTEM\\CurrentControlSet\\Services\\LanmanServer\\Parameters", - "OriginalValue": "1", + "OriginalValue": "20", "name": "IRPStackSize", - "value": "20", + "value": "30", "type": "Dword" }, { @@ -803,13 +1777,6 @@ } icacls $autoLoggerDir /deny SYSTEM:`(OI`)`(CI`)F | Out-Null - #Timeout Tweaks cause flickering on Windows now - #Remove-ItemProperty -Path \"HKCU:\\Control Panel\\Desktop\" -Name \"WaitToKillAppTimeout\" -ErrorAction SilentlyContinue - #Remove-ItemProperty -Path \"HKCU:\\Control Panel\\Desktop\" -Name \"HungAppTimeout\" -ErrorAction SilentlyContinue - #Remove-ItemProperty -Path \"HKLM:\\SYSTEM\\CurrentControlSet\\Control\" -Name \"WaitToKillServiceTimeout\" -ErrorAction SilentlyContinue - #Remove-ItemProperty -Path \"HKCU:\\Control Panel\\Desktop\" -Name \"LowLevelHooksTimeout\" -ErrorAction SilentlyContinue - #Remove-ItemProperty -Path \"HKCU:\\Control Panel\\Desktop\" -Name \"WaitToKillServiceTimeout\" -ErrorAction SilentlyContinue - $ram = (Get-CimInstance -ClassName \"Win32_PhysicalMemory\" | Measure-Object -Property Capacity -Sum).Sum / 1kb Set-ItemProperty -Path \"HKLM:\\SYSTEM\\CurrentControlSet\\Control\" -Name \"SvcHostSplitThresholdInKB\" -Type DWord -Value $ram -Force " @@ -1077,7 +2044,7 @@ }, "WPFEssTweaksOO": { "InvokeScript": [ - "curl.exe -s \"https://raw.githubusercontent.com/ChrisTitusTech/winutil/main/ooshutup10.cfg\" -o $ENV:temp\\ooshutup10.cfg + "curl.exe -s \"https://raw.githubusercontent.com/ChrisTitusTech/winutil/main/ooshutup10_winutil_settings.cfg\" -o $ENV:temp\\ooshutup10.cfg curl.exe -s \"https://dl5.oo-software.com/files/ooshutup10/OOSU10.exe\" -o $ENV:temp\\OOSU10.exe Start-Process $ENV:temp\\OOSU10.exe -ArgumentList \"$ENV:temp\\ooshutup10.cfg /quiet\" " @@ -1268,7 +2235,11 @@ "Value": "0", "OriginalValue": "1", "Type": "DWord" - }, + } + ] + }, + "WPFDisableGameBar": { + "registry": [ { "Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows\\GameDVR", "Name": "AllowGameDVR", diff --git a/functions/private/Get-WinUtilCheckBoxes.ps1 b/functions/private/Get-WinUtilCheckBoxes.ps1 index a227da62..f243c970 100644 --- a/functions/private/Get-WinUtilCheckBoxes.ps1 +++ b/functions/private/Get-WinUtilCheckBoxes.ps1 @@ -22,10 +22,11 @@ Function Get-WinUtilCheckBoxes { $Output = New-Object System.Collections.Generic.List[System.Object] if($Group -eq "WPFInstall"){ - $CheckBoxes = get-variable | Where-Object {$psitem.name -like "WPFInstall*" -and $psitem.value.GetType().name -eq "CheckBox"} + $filter = Get-WinUtilVariables -Type Checkbox | Where-Object {$psitem -like "WPFInstall*"} + $CheckBoxes = $sync.GetEnumerator() | Where-Object {$psitem.Key -in $filter} Foreach ($CheckBox in $CheckBoxes){ if($CheckBox.value.ischecked -eq $true){ - $sync.configs.applications.$($CheckBox.name).winget -split ";" | ForEach-Object { + $sync.configs.applications.$($CheckBox.Name).winget -split ";" | ForEach-Object { $Output.Add($psitem) } if ($uncheck -eq $true){ @@ -35,8 +36,24 @@ Function Get-WinUtilCheckBoxes { } } } + if($Group -eq "WPFTweaks"){ - $CheckBoxes = get-variable | Where-Object {$psitem.name -like "WPF*Tweaks*" -and $psitem.value.GetType().name -eq "CheckBox"} + $filter = Get-WinUtilVariables -Type Checkbox | Where-Object {$psitem -like "WPF*Tweaks*"} + $CheckBoxes = $sync.GetEnumerator() | Where-Object {$psitem.Key -in $filter} + Foreach ($CheckBox in $CheckBoxes){ + if($CheckBox.value.ischecked -eq $true){ + $Output.Add($Checkbox.Name) + + if ($uncheck -eq $true){ + $CheckBox.value.ischecked = $false + } + } + } + } + + if($Group -eq "WPFFeature"){ + $filter = Get-WinUtilVariables -Type Checkbox | Where-Object {$psitem -like "WPF*Feature*"} + $CheckBoxes = $sync.GetEnumerator() | Where-Object {$psitem.Key -in $filter} Foreach ($CheckBox in $CheckBoxes){ if($CheckBox.value.ischecked -eq $true){ $Output.Add($Checkbox.Name) diff --git a/functions/private/Get-WinUtilRegistry.ps1 b/functions/private/Get-WinUtilRegistry.ps1 new file mode 100644 index 00000000..33345a20 --- /dev/null +++ b/functions/private/Get-WinUtilRegistry.ps1 @@ -0,0 +1,33 @@ +function Get-WinUtilRegistry { + <# + + .DESCRIPTION + This function will make all modifications to the registry + + .EXAMPLE + + Set-WinUtilRegistry -Name "PublishUserActivities" -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Type "DWord" -Value "0" + + #> + param ( + $Name, + $Path, + $Type, + $Value + ) + + Try{ + $syscheckvalue = Get-ItemPropertyValue -Path $Path -Value $Value # Return Value + + } + Catch [System.Security.SecurityException] { + Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception" + } + Catch [System.Management.Automation.ItemNotFoundException] { + Write-Warning $psitem.Exception.ErrorRecord + } + Catch{ + Write-Warning "Unable to set $Name due to unhandled exception" + Write-Warning $psitem.Exception.StackTrace + } +} diff --git a/functions/private/Get-WinUtilVariables.ps1 b/functions/private/Get-WinUtilVariables.ps1 new file mode 100644 index 00000000..6c64099f --- /dev/null +++ b/functions/private/Get-WinUtilVariables.ps1 @@ -0,0 +1,29 @@ +function Get-WinUtilVariables { + + <# + + .DESCRIPTION + palceholder + + #> + param ( + [Parameter()] + [ValidateSet("CheckBox", "Button")] + [string]$Type + ) + + $keys = $sync.keys | Where-Object {$psitem -like "WPF*"} + + if($type){ + $output = $keys | ForEach-Object { + Try{ + if ($sync["$psitem"].GetType() -like "*$type*"){ + Write-Output $psitem + } + } + Catch{<#I am here so errors don't get outputted for a couple variables that don't have the .GetType() attribute#>} + } + return $output + } + return $keys +} diff --git a/functions/private/Install-WinUtilProgramWinget.ps1 b/functions/private/Install-WinUtilProgramWinget.ps1 index 798ea339..80cfb60d 100644 --- a/functions/private/Install-WinUtilProgramWinget.ps1 +++ b/functions/private/Install-WinUtilProgramWinget.ps1 @@ -9,20 +9,29 @@ Function Install-WinUtilProgramWinget { #> - param($ProgramsToInstall) + param( + $ProgramsToInstall, + $manage = "Installing" + ) $x = 0 $count = $($ProgramsToInstall -split ",").Count - Write-Progress -Activity "Installing Applications" -Status "Starting" -PercentComplete 0 + Write-Progress -Activity "$manage Applications" -Status "Starting" -PercentComplete 0 Foreach ($Program in $($ProgramsToInstall -split ",")){ - Write-Progress -Activity "Installing Applications" -Status "Installing $Program $($x + 1) of $count" -PercentComplete $($x/$count*100) - Start-Process -FilePath winget -ArgumentList "install -e --accept-source-agreements --accept-package-agreements --silent $Program" -NoNewWindow -Wait; + Write-Progress -Activity "$manage Applications" -Status "$manage $Program $($x + 1) of $count" -PercentComplete $($x/$count*100) + if($manage -eq "Installing"){ + Start-Process -FilePath winget -ArgumentList "install -e --accept-source-agreements --accept-package-agreements --silent $Program" -NoNewWindow -Wait + } + if($manage -eq "Uninstalling"){ + Start-Process -FilePath winget -ArgumentList "remove -e --purge --force --silent $Program" -NoNewWindow -Wait + } + $X++ } - Write-Progress -Activity "Installing Applications" -Status "Finished" -Completed + Write-Progress -Activity "$manage Applications" -Status "Finished" -Completed } diff --git a/functions/private/Install-WinUtilWinget.ps1 b/functions/private/Install-WinUtilWinget.ps1 index 9a15041d..b62c172b 100644 --- a/functions/private/Install-WinUtilWinget.ps1 +++ b/functions/private/Install-WinUtilWinget.ps1 @@ -42,6 +42,14 @@ function Install-WinUtilWinget { # Switching to winget-install from PSGallery from asheroto # Source: https://github.com/asheroto/winget-installer + #adding the code from the asheroto repo + Set-ExecutionPolicy RemoteSigned -force + Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force + Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted + Install-Script -Name winget-install -force + winget-instal + + Start-Process powershell.exe -Verb RunAs -ArgumentList "-command irm https://raw.githubusercontent.com/ChrisTitusTech/winutil/$BranchToUse/winget.ps1 | iex | Out-Host" -WindowStyle Normal -ErrorAction Stop if(!(Test-WinUtilPackageManager -winget)){ diff --git a/functions/private/Invoke-WinUtilCurrentSystem.ps1 b/functions/private/Invoke-WinUtilCurrentSystem.ps1 new file mode 100644 index 00000000..6612e561 --- /dev/null +++ b/functions/private/Invoke-WinUtilCurrentSystem.ps1 @@ -0,0 +1,100 @@ +Function Invoke-WinUtilCurrentSystem { + + <# + + .DESCRIPTION + Function is meant to read existing system registry and check according configuration. + + Example: Is telemetry enabled? check the box. + + .EXAMPLE + + Get-WinUtilCheckBoxes "WPFInstall" + + #> + + param( + $CheckBox + ) + + if ($checkbox -eq "winget"){ + + $originalEncoding = [Console]::OutputEncoding + [Console]::OutputEncoding = [System.Text.UTF8Encoding]::new() + $Sync.InstalledPrograms = winget list -s winget | Select-Object -skip 3 | ConvertFrom-String -PropertyNames "Name", "Id", "Version", "Available" -Delimiter '\s{2,}' + [Console]::OutputEncoding = $originalEncoding + + $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 + } + } + } + + if($CheckBox -eq "tweaks"){ + + if(!(Test-Path 'HKU:\')){New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS} + $ScheduledTasks = Get-ScheduledTask + + $sync.configs.tweaks | Get-Member -MemberType NoteProperty | ForEach-Object { + + $Config = $psitem.Name + #WPFEssTweaksTele + $registryKeys = $sync.configs.tweaks.$Config.registry + $scheduledtaskKeys = $sync.configs.tweaks.$Config.scheduledtask + $serviceKeys = $sync.configs.tweaks.$Config.service + + if($registryKeys -or $scheduledtaskKeys -or $serviceKeys){ + $Values = @() + + + Foreach ($tweaks in $registryKeys){ + Foreach($tweak in $tweaks){ + + if(test-path $tweak.Path){ + $actualValue = Get-ItemProperty -Name $tweak.Name -Path $tweak.Path -ErrorAction SilentlyContinue | Select-Object -ExpandProperty $($tweak.Name) + $expectedValue = $tweak.Value + if ($expectedValue -notlike $actualValue){ + $values += $False + } + } + } + } + + Foreach ($tweaks in $scheduledtaskKeys){ + Foreach($tweak in $tweaks){ + $task = $ScheduledTasks | Where-Object {$($psitem.TaskPath + $psitem.TaskName) -like "\$($tweak.name)"} + + if($task){ + $actualValue = $task.State + $expectedValue = $tweak.State + if ($expectedValue -ne $actualValue){ + $values += $False + } + } + } + } + + Foreach ($tweaks in $serviceKeys){ + Foreach($tweak in $tweaks){ + $Service = Get-Service -Name $tweak.Name + + if($Service){ + $actualValue = $Service.StartType + $expectedValue = $tweak.StartupType + if ($expectedValue -ne $actualValue){ + $values += $False + } + } + } + } + + if($values -notcontains $false){ + Write-Output $Config + } + } + } + } +} + diff --git a/functions/private/Invoke-WinUtilFeatureInstall.ps1 b/functions/private/Invoke-WinUtilFeatureInstall.ps1 new file mode 100644 index 00000000..e5968ee5 --- /dev/null +++ b/functions/private/Invoke-WinUtilFeatureInstall.ps1 @@ -0,0 +1,53 @@ +function Invoke-WinUtilFeatureInstall { + <# + + .DESCRIPTION + This function converts all the values from the tweaks.json and routes them to the appropriate function + + #> + + param( + $CheckBox + ) + + $CheckBox | ForEach-Object { + if($sync.configs.feature.$psitem.feature){ + Foreach( $feature in $sync.configs.feature.$psitem.feature ){ + Try{ + Write-Host "Installing $feature" + Enable-WindowsOptionalFeature -Online -FeatureName $feature -All -NoRestart + } + Catch{ + if ($psitem.Exception.Message -like "*requires elevation*"){ + Write-Warning "Unable to Install $feature due to permissions. Are you running as admin?" + } + + else{ + Write-Warning "Unable to Install $feature due to unhandled exception" + Write-Warning $psitem.Exception.StackTrace + } + } + } + } + if($sync.configs.feature.$psitem.InvokeScript){ + Foreach( $script in $sync.configs.feature.$psitem.InvokeScript ){ + Try{ + $Scriptblock = [scriptblock]::Create($script) + + Write-Host "Running Script for $psitem" + Invoke-Command $scriptblock -ErrorAction stop + } + Catch{ + if ($psitem.Exception.Message -like "*requires elevation*"){ + Write-Warning "Unable to Install $feature due to permissions. Are you running as admin?" + } + + else{ + Write-Warning "Unable to Install $feature due to unhandled exception" + Write-Warning $psitem.Exception.StackTrace + } + } + } + } + } +} diff --git a/functions/public/Invoke-WPFButton.ps1 b/functions/public/Invoke-WPFButton.ps1 index 07cf642f..a140f99a 100644 --- a/functions/public/Invoke-WPFButton.ps1 +++ b/functions/public/Invoke-WPFButton.ps1 @@ -18,13 +18,17 @@ function Invoke-WPFButton { "WPFTab?BT" {Invoke-WPFTab $Button} "WPFinstall" {Invoke-WPFInstall} + "WPFuninstall" {Invoke-WPFUnInstall} "WPFInstallUpgrade" {Invoke-WPFInstallUpgrade} "WPFdesktop" {Invoke-WPFPresets "Desktop"} "WPFlaptop" {Invoke-WPFPresets "laptop"} "WPFminimal" {Invoke-WPFPresets "minimal"} - "WPFexport" {Invoke-WPFImpex -type "export"} - "WPFimport" {Invoke-WPFImpex -type "import"} + "WPFexport" {Invoke-WPFImpex -type "export" -CheckBox "WPFTweaks"} + "WPFimport" {Invoke-WPFImpex -type "import" -CheckBox "WPFTweaks"} + "WPFexportWinget" {Invoke-WPFImpex -type "export" -CheckBox "WPFInstall"} + "WPFimportWinget" {Invoke-WPFImpex -type "import" -CheckBox "WPFInstall"} "WPFclear" {Invoke-WPFPresets -preset $null -imported $true} + "WPFclearWinget" {Invoke-WPFPresets -preset $null -imported $true -CheckBox "WPFInstall"} "WPFtweaksbutton" {Invoke-WPFtweaksbutton} "WPFAddUltPerf" {Invoke-WPFUltimatePerformance -State "Enabled"} "WPFRemoveUltPerf" {Invoke-WPFUltimatePerformance -State "Disabled"} @@ -43,7 +47,8 @@ function Invoke-WPFButton { "WPFFixesUpdate" {Invoke-WPFFixesUpdate} "WPFUpdatesdisable" {Invoke-WPFUpdatesdisable} "WPFUpdatessecurity" {Invoke-WPFUpdatessecurity} - - + "WPFWinUtilShortcut" {Invoke-WPFShortcut -ShortcutToAdd "WinUtil"} + "WPFGetInstalled" {Invoke-WPFGetInstalled -CheckBox "winget"} + "WPFGetInstalledTweaks" {Invoke-WPFGetInstalled -CheckBox "tweaks"} } } \ No newline at end of file diff --git a/functions/public/Invoke-WPFFeatureInstall.ps1 b/functions/public/Invoke-WPFFeatureInstall.ps1 index 3cc3488b..70411ce0 100644 --- a/functions/public/Invoke-WPFFeatureInstall.ps1 +++ b/functions/public/Invoke-WPFFeatureInstall.ps1 @@ -5,52 +5,33 @@ function Invoke-WPFFeatureInstall { GUI Function to install Windows Features #> - If ( $WPFFeaturesdotnet.IsChecked -eq $true ) { - Enable-WindowsOptionalFeature -Online -FeatureName "NetFx4-AdvSrvs" -All -NoRestart - Enable-WindowsOptionalFeature -Online -FeatureName "NetFx3" -All -NoRestart - } - If ( $WPFFeatureshyperv.IsChecked -eq $true ) { - Enable-WindowsOptionalFeature -Online -FeatureName "HypervisorPlatform" -All -NoRestart - Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Hyper-V-All" -All -NoRestart - Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Hyper-V" -All -NoRestart - Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Hyper-V-Tools-All" -All -NoRestart - Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Hyper-V-Management-PowerShell" -All -NoRestart - Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Hyper-V-Hypervisor" -All -NoRestart - Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Hyper-V-Services" -All -NoRestart - Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Hyper-V-Management-Clients" -All -NoRestart - cmd /c bcdedit /set hypervisorschedulertype classic - Write-Host "HyperV is now installed and configured. Please Reboot before using." - } - If ( $WPFFeatureslegacymedia.IsChecked -eq $true ) { - Enable-WindowsOptionalFeature -Online -FeatureName "WindowsMediaPlayer" -All -NoRestart - Enable-WindowsOptionalFeature -Online -FeatureName "MediaPlayback" -All -NoRestart - Enable-WindowsOptionalFeature -Online -FeatureName "DirectPlay" -All -NoRestart - Enable-WindowsOptionalFeature -Online -FeatureName "LegacyComponents" -All -NoRestart - } - If ( $WPFFeaturewsl.IsChecked -eq $true ) { - Enable-WindowsOptionalFeature -Online -FeatureName "VirtualMachinePlatform" -All -NoRestart - Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Windows-Subsystem-Linux" -All -NoRestart - Write-Host "WSL is now installed and configured. Please Reboot before using." - } - If ( $WPFFeaturenfs.IsChecked -eq $true ) { - Enable-WindowsOptionalFeature -Online -FeatureName "ServicesForNFS-ClientOnly" -All -NoRestart - Enable-WindowsOptionalFeature -Online -FeatureName "ClientForNFS-Infrastructure" -All -NoRestart - Enable-WindowsOptionalFeature -Online -FeatureName "NFS-Administration" -All -NoRestart - nfsadmin client stop - Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default" -Name "AnonymousUID" -Type DWord -Value 0 - Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default" -Name "AnonymousGID" -Type DWord -Value 0 - nfsadmin client start - nfsadmin client localhost config fileaccess=755 SecFlavors=+sys -krb5 -krb5i - Write-Host "NFS is now setup for user based NFS mounts" - } - $ButtonType = [System.Windows.MessageBoxButton]::OK - $MessageboxTitle = "All features are now installed " - $Messageboxbody = ("Done") - $MessageIcon = [System.Windows.MessageBoxImage]::Information - [System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon) + if($sync.ProcessRunning){ + $msg = "Install process is currently running." + [System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning) + return + } - Write-Host "=================================" - Write-Host "--- Features are Installed ---" - Write-Host "=================================" + $Features = Get-WinUtilCheckBoxes -Group "WPFFeature" + + Invoke-WPFRunspace -ArgumentList $Features -ScriptBlock { + param($Features) + + $sync.ProcessRunning = $true + + Invoke-WinUtilFeatureInstall $Features + + $sync.ProcessRunning = $false + Write-Host "===================================" + Write-Host "--- Features are Installed ---" + Write-Host "--- A Reboot may be required ---" + Write-Host "===================================" + + $ButtonType = [System.Windows.MessageBoxButton]::OK + $MessageboxTitle = "All features are now installed " + $Messageboxbody = ("Done") + $MessageIcon = [System.Windows.MessageBoxImage]::Information + + [System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon) + } } \ No newline at end of file diff --git a/functions/public/Invoke-WPFGetInstalled.ps1 b/functions/public/Invoke-WPFGetInstalled.ps1 new file mode 100644 index 00000000..09a296fb --- /dev/null +++ b/functions/public/Invoke-WPFGetInstalled.ps1 @@ -0,0 +1,46 @@ +function Invoke-WPFGetInstalled { + <# + + .DESCRIPTION + placeholder + + #> + param($checkbox) + + if($sync.ProcessRunning){ + $msg = "Install process is currently running." + [System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning) + return + } + + if(!(Test-WinUtilPackageManager -winget) -and $checkbox -eq "winget"){ + Write-Host "===========================================" + Write-Host "-- Winget is not installed ---" + Write-Host "===========================================" + return + } + + Invoke-WPFRunspace -ArgumentList $checkbox -ScriptBlock { + param($checkbox) + + $sync.ProcessRunning = $true + + if($checkbox -eq "winget"){ + Write-Host "Getting Installed Programs..." + } + if($checkbox -eq "tweaks"){ + Write-Host "Getting Installed Tweaks..." + } + + $Checkboxes = Invoke-WinUtilCurrentSystem -CheckBox $checkbox + + $sync.form.Dispatcher.invoke({ + foreach($checkbox in $Checkboxes){ + $sync.$checkbox.ischecked = $True + } + }) + + Write-Host "Done..." + $sync.ProcessRunning = $false + } +} \ No newline at end of file diff --git a/functions/public/Invoke-WPFImpex.ps1 b/functions/public/Invoke-WPFImpex.ps1 index 2c1f832b..a6a14b23 100644 --- a/functions/public/Invoke-WPFImpex.ps1 +++ b/functions/public/Invoke-WPFImpex.ps1 @@ -9,7 +9,10 @@ function Invoke-WPFImpex { Invoke-WPFImpex -type "export" #> - param($type) + param( + $type, + $checkbox + ) if ($type -eq "export"){ $FileBrowser = New-Object System.Windows.Forms.SaveFileDialog @@ -27,11 +30,11 @@ function Invoke-WPFImpex { } if ($type -eq "export"){ - $jsonFile = Get-WinUtilCheckBoxes WPFTweaks -unCheck $false + $jsonFile = Get-WinUtilCheckBoxes $checkbox -unCheck $false $jsonFile | ConvertTo-Json | Out-File $FileBrowser.FileName -Force } if ($type -eq "import"){ $jsonFile = Get-Content $FileBrowser.FileName | ConvertFrom-Json - Invoke-WPFPresets -preset $jsonFile -imported $true + Invoke-WPFPresets -preset $jsonFile -imported $true -CheckBox $checkbox } } diff --git a/functions/public/Invoke-WPFPresets.ps1 b/functions/public/Invoke-WPFPresets.ps1 index 1b3bc193..edfbfaf3 100644 --- a/functions/public/Invoke-WPFPresets.ps1 +++ b/functions/public/Invoke-WPFPresets.ps1 @@ -8,8 +8,10 @@ function Invoke-WPFPresets { param( $preset, - [bool]$imported = $false + [bool]$imported = $false, + $checkbox = "WPFTeaks" ) + if($imported -eq $true){ $CheckBoxesToCheck = $preset } @@ -17,15 +19,23 @@ function Invoke-WPFPresets { $CheckBoxesToCheck = $sync.configs.preset.$preset } - #Uncheck all - get-variable | Where-Object {$_.name -like "*tweaks*"} | ForEach-Object { - if ($psitem.value.gettype().name -eq "CheckBox"){ - $CheckBox = Get-Variable $psitem.Name - if ($CheckBoxesToCheck -contains $CheckBox.name){ - $checkbox.value.ischecked = $true + if($checkbox -eq "WPFTeaks"){ + $filter = Get-WinUtilVariables -Type Checkbox | Where-Object {$psitem -like "*tweaks*"} + $sync.GetEnumerator() | Where-Object {$psitem.Key -in $filter} | ForEach-Object { + if ($CheckBoxesToCheck -contains $PSItem.name){ + $sync.$($PSItem.name).ischecked = $true } - else{$checkbox.value.ischecked = $false} + else{$sync.$($PSItem.name).ischecked = $false} } } + if($checkbox -eq "WPFInstall"){ + $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.name).winget) -in $CheckBoxesToCheck){ + $sync.$($PSItem.name).ischecked = $true + } + else{$sync.$($PSItem.name).ischecked = $false} + } + } } \ No newline at end of file diff --git a/functions/public/Invoke-WPFRunspace.ps1 b/functions/public/Invoke-WPFRunspace.ps1 index 5b9ec321..e00b42bf 100644 --- a/functions/public/Invoke-WPFRunspace.ps1 +++ b/functions/public/Invoke-WPFRunspace.ps1 @@ -23,40 +23,13 @@ function Invoke-WPFRunspace { $ArgumentList ) - #Configure max thread count for RunspacePool. - $maxthreads = [int]$env:NUMBER_OF_PROCESSORS - - #Create a new session state for parsing variables ie hashtable into our runspace. - $hashVars = New-object System.Management.Automation.Runspaces.SessionStateVariableEntry -ArgumentList 'sync',$sync,$Null - $InitialSessionState = [System.Management.Automation.Runspaces.InitialSessionState]::CreateDefault() - - #Add the variable to the RunspacePool sessionstate - $InitialSessionState.Variables.Add($hashVars) - - #Add functions - $functions = Get-ChildItem function:\ | Where-Object {$_.name -like "*winutil*" -or $_.name -like "*WPF*"} - foreach ($function in $functions){ - $functionDefinition = Get-Content function:\$($function.name) - $functionEntry = New-Object System.Management.Automation.Runspaces.SessionStateFunctionEntry -ArgumentList $($function.name), $functionDefinition - - # And add it to the iss object - $initialSessionState.Commands.Add($functionEntry) - } - - #Create our runspace pool. We are entering three parameters here min thread count, max thread count and host machine of where these runspaces should be made. - $script:runspace = [runspacefactory]::CreateRunspacePool(1,$maxthreads,$InitialSessionState, $Host) - - #Crate a PowerShell instance. $script:powershell = [powershell]::Create() - #Open a RunspacePool instance. - $script:runspace.Open() - #Add Scriptblock and Arguments to runspace $script:powershell.AddScript($ScriptBlock) $script:powershell.AddArgument($ArgumentList) - $script:powershell.RunspacePool = $script:runspace + $script:powershell.RunspacePool = $sync.runspace #Run our RunspacePool. $script:handle = $script:powershell.BeginInvoke() @@ -66,8 +39,8 @@ function Invoke-WPFRunspace { { $script:powershell.EndInvoke($script:handle) $script:powershell.Dispose() - $script:runspace.Dispose() - $script:runspace.Close() + $sync.runspace.Dispose() + $sync.runspace.Close() [System.GC]::Collect() } } \ No newline at end of file diff --git a/functions/public/Invoke-WPFShortcut.ps1 b/functions/public/Invoke-WPFShortcut.ps1 new file mode 100644 index 00000000..1b0377f8 --- /dev/null +++ b/functions/public/Invoke-WPFShortcut.ps1 @@ -0,0 +1,33 @@ +function Invoke-WPFShortcut { + <# + + .DESCRIPTION + Creates a shortcut + + #> + param($ShortcutToAdd) + + Switch ($ShortcutToAdd) { + "WinUtil" { + $SourceExe = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" + $IRM = 'irm https://christitus.com/win | iex' + $Powershell = '-ExecutionPolicy Bypass -Command "Start-Process powershell.exe -verb runas -ArgumentList' + $ArgumentsToSourceExe = "$powershell '$IRM'" + $DestinationName = "WinUtil.lnk" + } + } + + $FileBrowser = New-Object System.Windows.Forms.SaveFileDialog + $FileBrowser.InitialDirectory = [Environment]::GetFolderPath('Desktop') + $FileBrowser.Filter = "Shortcut Files (*.lnk)|*.lnk" + $FileBrowser.FileName = $DestinationName + $FileBrowser.ShowDialog() | Out-Null + + $WshShell = New-Object -comObject WScript.Shell + $Shortcut = $WshShell.CreateShortcut($FileBrowser.FileName) + $Shortcut.TargetPath = $SourceExe + $Shortcut.Arguments = $ArgumentsToSourceExe + $Shortcut.Save() + + Write-Host "Shortcut for $ShortcutToAdd has been saved to $($FileBrowser.FileName)" +} \ No newline at end of file diff --git a/functions/public/Invoke-WPFTab.ps1 b/functions/public/Invoke-WPFTab.ps1 index 46c68712..0c95d258 100644 --- a/functions/public/Invoke-WPFTab.ps1 +++ b/functions/public/Invoke-WPFTab.ps1 @@ -8,17 +8,17 @@ function Invoke-WPFTab { #> Param ($ClickedTab) - $Tabs = Get-Variable WPFTab?BT - $TabNav = Get-Variable WPFTabNav + $Tabs = Get-WinUtilVariables | Where-Object {$psitem -like "WPFTab?BT"} + $TabNav = Get-WinUtilVariables | Where-Object {$psitem -like "WPFTabNav"} $x = [int]($ClickedTab -replace "WPFTab","" -replace "BT","") - 1 0..($Tabs.Count -1 ) | ForEach-Object { if ($x -eq $psitem){ - $TabNav.value.Items[$psitem].IsSelected = $true + $sync.$TabNav.Items[$psitem].IsSelected = $true } else{ - $TabNav.value.Items[$psitem].IsSelected = $false + $sync.$TabNav.Items[$psitem].IsSelected = $false } } } diff --git a/functions/public/Invoke-WPFUnInstall.ps1 b/functions/public/Invoke-WPFUnInstall.ps1 new file mode 100644 index 00000000..2205db15 --- /dev/null +++ b/functions/public/Invoke-WPFUnInstall.ps1 @@ -0,0 +1,58 @@ +function Invoke-WPFUnInstall { + <# + + .DESCRIPTION + PlaceHolder + + #> + + if($sync.ProcessRunning){ + $msg = "Install process is currently running." + [System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning) + return + } + + $WingetInstall = Get-WinUtilCheckBoxes -Group "WPFInstall" + + if ($wingetinstall.Count -eq 0) { + $WarningMsg = "Please select the program(s) to install" + [System.Windows.MessageBox]::Show($WarningMsg, $AppTitle, [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning) + return + } + + $ButtonType = [System.Windows.MessageBoxButton]::YesNo + $MessageboxTitle = "Are you sure?" + $Messageboxbody = ("This will uninstall the following applications `n $WingetInstall") + $MessageIcon = [System.Windows.MessageBoxImage]::Information + + $confirm = [System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon) + + if($confirm -eq "No"){return} + + Invoke-WPFRunspace -ArgumentList $WingetInstall -scriptblock { + param($WingetInstall) + try{ + $sync.ProcessRunning = $true + + # Install all winget programs in new window + Install-WinUtilProgramWinget -ProgramsToInstall $WingetInstall -Manage "Uninstalling" + + $ButtonType = [System.Windows.MessageBoxButton]::OK + $MessageboxTitle = "Uninstalls are Finished " + $Messageboxbody = ("Done") + $MessageIcon = [System.Windows.MessageBoxImage]::Information + + [System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon) + + Write-Host "===========================================" + Write-Host "-- Uninstalls have finished ---" + Write-Host "===========================================" + } + Catch { + Write-Host "===========================================" + Write-Host "-- Winget failed to install ---" + Write-Host "===========================================" + } + $sync.ProcessRunning = $False + } +} \ No newline at end of file diff --git a/functions/public/Invoke-WPFtweaksbutton.ps1 b/functions/public/Invoke-WPFtweaksbutton.ps1 index 243242e2..ef3031cd 100644 --- a/functions/public/Invoke-WPFtweaksbutton.ps1 +++ b/functions/public/Invoke-WPFtweaksbutton.ps1 @@ -1,20 +1,26 @@ function Invoke-WPFtweaksbutton { <# - - .DESCRIPTION - PlaceHolder - - #> + + .DESCRIPTION + PlaceHolder + + #> if($sync.ProcessRunning){ $msg = "Install process is currently running." [System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning) return -} + } $Tweaks = Get-WinUtilCheckBoxes -Group "WPFTweaks" - Set-WinUtilDNS -DNSProvider $WPFchangedns.text + Set-WinUtilDNS -DNSProvider $sync["WPFchangedns"].text + + if ($tweaks.count -eq 0 -and $sync["WPFchangedns"].text -eq "Default"){ + $msg = "Please check the tweaks you wish to perform." + [System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning) + return + } Invoke-WPFRunspace -ArgumentList $Tweaks -ScriptBlock { param($Tweaks) diff --git a/functions/public/Invoke-WPFundoall.ps1 b/functions/public/Invoke-WPFundoall.ps1 index b7b7d8c0..272636d3 100644 --- a/functions/public/Invoke-WPFundoall.ps1 +++ b/functions/public/Invoke-WPFundoall.ps1 @@ -11,30 +11,36 @@ function Invoke-WPFundoall { [System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning) return } + + $Tweaks = Get-WinUtilCheckBoxes -Group "WPFTweaks" + + if ($tweaks.count -eq 0){ + $msg = "Please check the tweaks you wish to undo." + [System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning) + return + } - $Tweaks = Get-WinUtilCheckBoxes -Group "WPFTweaks" - - Invoke-WPFRunspace -ArgumentList $Tweaks -ScriptBlock { + Invoke-WPFRunspace -ArgumentList $Tweaks -ScriptBlock { param($Tweaks) - + $sync.ProcessRunning = $true - + Foreach ($tweak in $tweaks){ Invoke-WinUtilTweaks $tweak -undo $true } - + $sync.ProcessRunning = $false Write-Host "==================================" Write-Host "--- Undo Tweaks are Finished ---" Write-Host "==================================" - + $ButtonType = [System.Windows.MessageBoxButton]::OK $MessageboxTitle = "Tweaks are Finished " $Messageboxbody = ("Done") $MessageIcon = [System.Windows.MessageBoxImage]::Information - + [System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon) - } + } <# diff --git a/pester/runspace.Tests.ps1 b/pester/configs.Tests.ps1 similarity index 75% rename from pester/runspace.Tests.ps1 rename to pester/configs.Tests.ps1 index 64faf47b..85a72f3b 100644 --- a/pester/runspace.Tests.ps1 +++ b/pester/configs.Tests.ps1 @@ -1,16 +1,3 @@ -#region Configurable Variables - - <# - .NOTES - Use this section to configure testing variables. IE if the number of tabs change in the GUI update that variable here. - All variables need to be global to be passed between contexts - - #> - - $global:FormName = "Chris Titus Tech's Windows Utility" - -#endregion Configurable Variables - #region Load Variables needed for testing #Config Files @@ -91,25 +78,4 @@ Describe "Config Files" -ForEach @( } } -} - - -#=========================================================================== -# Tests - Functions -#=========================================================================== - -Describe "Functions" -ForEach @(Get-ChildItem .\functions -Recurse -File){ - - BeforeEach -Scriptblock { - . $psitem.FullName - } - - Context "$($psitem.BaseName)" { - It "Imports with no errors" { - Get-ChildItem function:\$($psitem.BaseName) | should -Not -BeNullOrEmpty - } - It "Contains Description" { - get-help $($psitem.BaseName) -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Description | should -Not -BeNullOrEmpty - } - } -} +} \ No newline at end of file diff --git a/pester/functions.Tests.ps1 b/pester/functions.Tests.ps1 new file mode 100644 index 00000000..093abfe2 --- /dev/null +++ b/pester/functions.Tests.ps1 @@ -0,0 +1,28 @@ +#=========================================================================== +# Tests - Functions +#=========================================================================== + +Describe "Functions"{ + + Get-ChildItem .\functions -Recurse -File | ForEach-Object { + + context "$($psitem.BaseName)" { + BeforeEach -Scriptblock { + . $fullname + } + + It "Imports with no errors" -TestCases @{ + basename = $($psitem.BaseName) + fullname = $psitem.FullName + } { + Get-ChildItem function:\$basename | should -Not -BeNullOrEmpty + } + It "Contains Description" -TestCases @{ + basename = $($psitem.BaseName) + fullname = $psitem.FullName + } { + get-help $basename -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Description | should -Not -BeNullOrEmpty + } + } + } +} diff --git a/pester/winutil.Tests.ps1 b/pester/winutil.Tests.ps1 index 649faad9..b1752ce6 100644 --- a/pester/winutil.Tests.ps1 +++ b/pester/winutil.Tests.ps1 @@ -1,208 +1,27 @@ -#region Configurable Variables - - <# - .NOTES - Use this section to configure testing variables. IE if the number of tabs change in the GUI update that variable here. - All variables need to be global to be passed between contexts - - #> - - $global:FormName = "Chris Titus Tech's Windows Utility" - -#endregion Configurable Variables - #region Load Variables needed for testing - #Config Files - $global:configs = @{} + ./Compile.ps1 - ( - "applications", - "preset" - ) | ForEach-Object { - $global:configs["$PSItem"] = Get-Content .\config\$PSItem.json | ConvertFrom-Json - } - - #GUI - $global:inputXML = get-content MainWindow.xaml - $global:inputXML = $global:inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^ Start-Transcript $ENV:TEMP\Winutil.log -Append @@ -21,7 +21,7 @@ Add-Type -AssemblyName System.Windows.Forms # variable to sync between runspaces $sync = [Hashtable]::Synchronized(@{}) $sync.PSScriptRoot = $PSScriptRoot -$sync.version = "23.03.07" +$sync.version = "23.05.09" $sync.configs = @{} $sync.ProcessRunning = $false Function Get-WinUtilCheckBoxes { @@ -48,10 +48,11 @@ Function Get-WinUtilCheckBoxes { $Output = New-Object System.Collections.Generic.List[System.Object] if($Group -eq "WPFInstall"){ - $CheckBoxes = get-variable | Where-Object {$psitem.name -like "WPFInstall*" -and $psitem.value.GetType().name -eq "CheckBox"} + $filter = Get-WinUtilVariables -Type Checkbox | Where-Object {$psitem -like "WPFInstall*"} + $CheckBoxes = $sync.GetEnumerator() | Where-Object {$psitem.Key -in $filter} Foreach ($CheckBox in $CheckBoxes){ if($CheckBox.value.ischecked -eq $true){ - $sync.configs.applications.$($CheckBox.name).winget -split ";" | ForEach-Object { + $sync.configs.applications.$($CheckBox.Name).winget -split ";" | ForEach-Object { $Output.Add($psitem) } if ($uncheck -eq $true){ @@ -61,8 +62,24 @@ Function Get-WinUtilCheckBoxes { } } } + if($Group -eq "WPFTweaks"){ - $CheckBoxes = get-variable | Where-Object {$psitem.name -like "WPF*Tweaks*" -and $psitem.value.GetType().name -eq "CheckBox"} + $filter = Get-WinUtilVariables -Type Checkbox | Where-Object {$psitem -like "WPF*Tweaks*"} + $CheckBoxes = $sync.GetEnumerator() | Where-Object {$psitem.Key -in $filter} + Foreach ($CheckBox in $CheckBoxes){ + if($CheckBox.value.ischecked -eq $true){ + $Output.Add($Checkbox.Name) + + if ($uncheck -eq $true){ + $CheckBox.value.ischecked = $false + } + } + } + } + + if($Group -eq "WPFFeature"){ + $filter = Get-WinUtilVariables -Type Checkbox | Where-Object {$psitem -like "WPF*Feature*"} + $CheckBoxes = $sync.GetEnumerator() | Where-Object {$psitem.Key -in $filter} Foreach ($CheckBox in $CheckBoxes){ if($CheckBox.value.ischecked -eq $true){ $Output.Add($Checkbox.Name) @@ -110,6 +127,68 @@ function Get-WinUtilInstallerProcess { } return $false } +function Get-WinUtilRegistry { + <# + + .DESCRIPTION + This function will make all modifications to the registry + + .EXAMPLE + + Set-WinUtilRegistry -Name "PublishUserActivities" -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Type "DWord" -Value "0" + + #> + param ( + $Name, + $Path, + $Type, + $Value + ) + + Try{ + $syscheckvalue = Get-ItemPropertyValue -Path $Path -Value $Value # Return Value + + } + Catch [System.Security.SecurityException] { + Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception" + } + Catch [System.Management.Automation.ItemNotFoundException] { + Write-Warning $psitem.Exception.ErrorRecord + } + Catch{ + Write-Warning "Unable to set $Name due to unhandled exception" + Write-Warning $psitem.Exception.StackTrace + } +} +function Get-WinUtilVariables { + + <# + + .DESCRIPTION + palceholder + + #> + param ( + [Parameter()] + [ValidateSet("CheckBox", "Button")] + [string]$Type + ) + + $keys = $sync.keys | Where-Object {$psitem -like "WPF*"} + + if($type){ + $output = $keys | ForEach-Object { + Try{ + if ($sync["$psitem"].GetType() -like "*$type*"){ + Write-Output $psitem + } + } + Catch{<#I am here so errors don't get outputted for a couple variables that don't have the .GetType() attribute#>} + } + return $output + } + return $keys +} function Install-WinUtilChoco { <# @@ -151,21 +230,30 @@ Function Install-WinUtilProgramWinget { #> - param($ProgramsToInstall) + param( + $ProgramsToInstall, + $manage = "Installing" + ) $x = 0 $count = $($ProgramsToInstall -split ",").Count - Write-Progress -Activity "Installing Applications" -Status "Starting" -PercentComplete 0 + Write-Progress -Activity "$manage Applications" -Status "Starting" -PercentComplete 0 Foreach ($Program in $($ProgramsToInstall -split ",")){ - Write-Progress -Activity "Installing Applications" -Status "Installing $Program $($x + 1) of $count" -PercentComplete $($x/$count*100) - Start-Process -FilePath winget -ArgumentList "install -e --accept-source-agreements --accept-package-agreements --silent $Program" -NoNewWindow -Wait; + Write-Progress -Activity "$manage Applications" -Status "$manage $Program $($x + 1) of $count" -PercentComplete $($x/$count*100) + if($manage -eq "Installing"){ + Start-Process -FilePath winget -ArgumentList "install -e --accept-source-agreements --accept-package-agreements --silent $Program" -NoNewWindow -Wait + } + if($manage -eq "Uninstalling"){ + Start-Process -FilePath winget -ArgumentList "remove -e --purge --force --silent $Program" -NoNewWindow -Wait + } + $X++ } - Write-Progress -Activity "Installing Applications" -Status "Finished" -Completed + Write-Progress -Activity "$manage Applications" -Status "Finished" -Completed } function Install-WinUtilWinget { @@ -212,6 +300,14 @@ function Install-WinUtilWinget { # Switching to winget-install from PSGallery from asheroto # Source: https://github.com/asheroto/winget-installer + #adding the code from the asheroto repo + Set-ExecutionPolicy RemoteSigned -force + Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force + Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted + Install-Script -Name winget-install -force + winget-instal + + Start-Process powershell.exe -Verb RunAs -ArgumentList "-command irm https://raw.githubusercontent.com/ChrisTitusTech/winutil/$BranchToUse/winget.ps1 | iex | Out-Host" -WindowStyle Normal -ErrorAction Stop if(!(Test-WinUtilPackageManager -winget)){ @@ -236,6 +332,159 @@ function Install-WinUtilWinget { throw [WingetFailedInstall]::new('Failed to install') } } +Function Invoke-WinUtilCurrentSystem { + + <# + + .DESCRIPTION + Function is meant to read existing system registry and check according configuration. + + Example: Is telemetry enabled? check the box. + + .EXAMPLE + + Get-WinUtilCheckBoxes "WPFInstall" + + #> + + param( + $CheckBox + ) + + if ($checkbox -eq "winget"){ + + $originalEncoding = [Console]::OutputEncoding + [Console]::OutputEncoding = [System.Text.UTF8Encoding]::new() + $Sync.InstalledPrograms = winget list -s winget | Select-Object -skip 3 | ConvertFrom-String -PropertyNames "Name", "Id", "Version", "Available" -Delimiter '\s{2,}' + [Console]::OutputEncoding = $originalEncoding + + $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 + } + } + } + + if($CheckBox -eq "tweaks"){ + + if(!(Test-Path 'HKU:\')){New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS} + $ScheduledTasks = Get-ScheduledTask + + $sync.configs.tweaks | Get-Member -MemberType NoteProperty | ForEach-Object { + + $Config = $psitem.Name + #WPFEssTweaksTele + $registryKeys = $sync.configs.tweaks.$Config.registry + $scheduledtaskKeys = $sync.configs.tweaks.$Config.scheduledtask + $serviceKeys = $sync.configs.tweaks.$Config.service + + if($registryKeys -or $scheduledtaskKeys -or $serviceKeys){ + $Values = @() + + + Foreach ($tweaks in $registryKeys){ + Foreach($tweak in $tweaks){ + + if(test-path $tweak.Path){ + $actualValue = Get-ItemProperty -Name $tweak.Name -Path $tweak.Path -ErrorAction SilentlyContinue | Select-Object -ExpandProperty $($tweak.Name) + $expectedValue = $tweak.Value + if ($expectedValue -notlike $actualValue){ + $values += $False + } + } + } + } + + Foreach ($tweaks in $scheduledtaskKeys){ + Foreach($tweak in $tweaks){ + $task = $ScheduledTasks | Where-Object {$($psitem.TaskPath + $psitem.TaskName) -like "\$($tweak.name)"} + + if($task){ + $actualValue = $task.State + $expectedValue = $tweak.State + if ($expectedValue -ne $actualValue){ + $values += $False + } + } + } + } + + Foreach ($tweaks in $serviceKeys){ + Foreach($tweak in $tweaks){ + $Service = Get-Service -Name $tweak.Name + + if($Service){ + $actualValue = $Service.StartType + $expectedValue = $tweak.StartupType + if ($expectedValue -ne $actualValue){ + $values += $False + } + } + } + } + + if($values -notcontains $false){ + Write-Output $Config + } + } + } + } +} + +function Invoke-WinUtilFeatureInstall { + <# + + .DESCRIPTION + This function converts all the values from the tweaks.json and routes them to the appropriate function + + #> + + param( + $CheckBox + ) + + $CheckBox | ForEach-Object { + if($sync.configs.feature.$psitem.feature){ + Foreach( $feature in $sync.configs.feature.$psitem.feature ){ + Try{ + Write-Host "Installing $feature" + Enable-WindowsOptionalFeature -Online -FeatureName $feature -All -NoRestart + } + Catch{ + if ($psitem.Exception.Message -like "*requires elevation*"){ + Write-Warning "Unable to Install $feature due to permissions. Are you running as admin?" + } + + else{ + Write-Warning "Unable to Install $feature due to unhandled exception" + Write-Warning $psitem.Exception.StackTrace + } + } + } + } + if($sync.configs.feature.$psitem.InvokeScript){ + Foreach( $script in $sync.configs.feature.$psitem.InvokeScript ){ + Try{ + $Scriptblock = [scriptblock]::Create($script) + + Write-Host "Running Script for $psitem" + Invoke-Command $scriptblock -ErrorAction stop + } + Catch{ + if ($psitem.Exception.Message -like "*requires elevation*"){ + Write-Warning "Unable to Install $feature due to permissions. Are you running as admin?" + } + + else{ + Write-Warning "Unable to Install $feature due to unhandled exception" + Write-Warning $psitem.Exception.StackTrace + } + } + } + } + } +} function Invoke-WinUtilScript { <# @@ -577,13 +826,17 @@ function Invoke-WPFButton { "WPFTab?BT" {Invoke-WPFTab $Button} "WPFinstall" {Invoke-WPFInstall} + "WPFuninstall" {Invoke-WPFUnInstall} "WPFInstallUpgrade" {Invoke-WPFInstallUpgrade} "WPFdesktop" {Invoke-WPFPresets "Desktop"} "WPFlaptop" {Invoke-WPFPresets "laptop"} "WPFminimal" {Invoke-WPFPresets "minimal"} - "WPFexport" {Invoke-WPFImpex -type "export"} - "WPFimport" {Invoke-WPFImpex -type "import"} + "WPFexport" {Invoke-WPFImpex -type "export" -CheckBox "WPFTweaks"} + "WPFimport" {Invoke-WPFImpex -type "import" -CheckBox "WPFTweaks"} + "WPFexportWinget" {Invoke-WPFImpex -type "export" -CheckBox "WPFInstall"} + "WPFimportWinget" {Invoke-WPFImpex -type "import" -CheckBox "WPFInstall"} "WPFclear" {Invoke-WPFPresets -preset $null -imported $true} + "WPFclearWinget" {Invoke-WPFPresets -preset $null -imported $true -CheckBox "WPFInstall"} "WPFtweaksbutton" {Invoke-WPFtweaksbutton} "WPFAddUltPerf" {Invoke-WPFUltimatePerformance -State "Enabled"} "WPFRemoveUltPerf" {Invoke-WPFUltimatePerformance -State "Disabled"} @@ -602,8 +855,9 @@ function Invoke-WPFButton { "WPFFixesUpdate" {Invoke-WPFFixesUpdate} "WPFUpdatesdisable" {Invoke-WPFUpdatesdisable} "WPFUpdatessecurity" {Invoke-WPFUpdatessecurity} - - + "WPFWinUtilShortcut" {Invoke-WPFShortcut -ShortcutToAdd "WinUtil"} + "WPFGetInstalled" {Invoke-WPFGetInstalled -CheckBox "winget"} + "WPFGetInstalledTweaks" {Invoke-WPFGetInstalled -CheckBox "tweaks"} } } function Invoke-WPFControlPanel { @@ -664,54 +918,35 @@ function Invoke-WPFFeatureInstall { GUI Function to install Windows Features #> - If ( $WPFFeaturesdotnet.IsChecked -eq $true ) { - Enable-WindowsOptionalFeature -Online -FeatureName "NetFx4-AdvSrvs" -All -NoRestart - Enable-WindowsOptionalFeature -Online -FeatureName "NetFx3" -All -NoRestart - } - If ( $WPFFeatureshyperv.IsChecked -eq $true ) { - Enable-WindowsOptionalFeature -Online -FeatureName "HypervisorPlatform" -All -NoRestart - Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Hyper-V-All" -All -NoRestart - Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Hyper-V" -All -NoRestart - Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Hyper-V-Tools-All" -All -NoRestart - Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Hyper-V-Management-PowerShell" -All -NoRestart - Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Hyper-V-Hypervisor" -All -NoRestart - Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Hyper-V-Services" -All -NoRestart - Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Hyper-V-Management-Clients" -All -NoRestart - cmd /c bcdedit /set hypervisorschedulertype classic - Write-Host "HyperV is now installed and configured. Please Reboot before using." - } - If ( $WPFFeatureslegacymedia.IsChecked -eq $true ) { - Enable-WindowsOptionalFeature -Online -FeatureName "WindowsMediaPlayer" -All -NoRestart - Enable-WindowsOptionalFeature -Online -FeatureName "MediaPlayback" -All -NoRestart - Enable-WindowsOptionalFeature -Online -FeatureName "DirectPlay" -All -NoRestart - Enable-WindowsOptionalFeature -Online -FeatureName "LegacyComponents" -All -NoRestart - } - If ( $WPFFeaturewsl.IsChecked -eq $true ) { - Enable-WindowsOptionalFeature -Online -FeatureName "VirtualMachinePlatform" -All -NoRestart - Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Windows-Subsystem-Linux" -All -NoRestart - Write-Host "WSL is now installed and configured. Please Reboot before using." - } - If ( $WPFFeaturenfs.IsChecked -eq $true ) { - Enable-WindowsOptionalFeature -Online -FeatureName "ServicesForNFS-ClientOnly" -All -NoRestart - Enable-WindowsOptionalFeature -Online -FeatureName "ClientForNFS-Infrastructure" -All -NoRestart - Enable-WindowsOptionalFeature -Online -FeatureName "NFS-Administration" -All -NoRestart - nfsadmin client stop - Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default" -Name "AnonymousUID" -Type DWord -Value 0 - Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default" -Name "AnonymousGID" -Type DWord -Value 0 - nfsadmin client start - nfsadmin client localhost config fileaccess=755 SecFlavors=+sys -krb5 -krb5i - Write-Host "NFS is now setup for user based NFS mounts" - } - $ButtonType = [System.Windows.MessageBoxButton]::OK - $MessageboxTitle = "All features are now installed " - $Messageboxbody = ("Done") - $MessageIcon = [System.Windows.MessageBoxImage]::Information - [System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon) + if($sync.ProcessRunning){ + $msg = "Install process is currently running." + [System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning) + return + } - Write-Host "=================================" - Write-Host "--- Features are Installed ---" - Write-Host "=================================" + $Features = Get-WinUtilCheckBoxes -Group "WPFFeature" + + Invoke-WPFRunspace -ArgumentList $Features -ScriptBlock { + param($Features) + + $sync.ProcessRunning = $true + + Invoke-WinUtilFeatureInstall $Features + + $sync.ProcessRunning = $false + Write-Host "===================================" + Write-Host "--- Features are Installed ---" + Write-Host "--- A Reboot may be required ---" + Write-Host "===================================" + + $ButtonType = [System.Windows.MessageBoxButton]::OK + $MessageboxTitle = "All features are now installed " + $Messageboxbody = ("Done") + $MessageIcon = [System.Windows.MessageBoxImage]::Information + + [System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon) + } } function Invoke-WPFFixesUpdate { @@ -861,6 +1096,52 @@ Function Invoke-WPFFormVariables { #Write-Host "Found the following interactable elements from our form" -ForegroundColor Cyan #get-variable WPF* } +function Invoke-WPFGetInstalled { + <# + + .DESCRIPTION + placeholder + + #> + param($checkbox) + + if($sync.ProcessRunning){ + $msg = "Install process is currently running." + [System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning) + return + } + + if(!(Test-WinUtilPackageManager -winget) -and $checkbox -eq "winget"){ + Write-Host "===========================================" + Write-Host "-- Winget is not installed ---" + Write-Host "===========================================" + return + } + + Invoke-WPFRunspace -ArgumentList $checkbox -ScriptBlock { + param($checkbox) + + $sync.ProcessRunning = $true + + if($checkbox -eq "winget"){ + Write-Host "Getting Installed Programs..." + } + if($checkbox -eq "tweaks"){ + Write-Host "Getting Installed Tweaks..." + } + + $Checkboxes = Invoke-WinUtilCurrentSystem -CheckBox $checkbox + + $sync.form.Dispatcher.invoke({ + foreach($checkbox in $Checkboxes){ + $sync.$checkbox.ischecked = $True + } + }) + + Write-Host "Done..." + $sync.ProcessRunning = $false + } +} function Invoke-WPFImpex { <# @@ -872,7 +1153,10 @@ function Invoke-WPFImpex { Invoke-WPFImpex -type "export" #> - param($type) + param( + $type, + $checkbox + ) if ($type -eq "export"){ $FileBrowser = New-Object System.Windows.Forms.SaveFileDialog @@ -890,12 +1174,12 @@ function Invoke-WPFImpex { } if ($type -eq "export"){ - $jsonFile = Get-WinUtilCheckBoxes WPFTweaks -unCheck $false + $jsonFile = Get-WinUtilCheckBoxes $checkbox -unCheck $false $jsonFile | ConvertTo-Json | Out-File $FileBrowser.FileName -Force } if ($type -eq "import"){ $jsonFile = Get-Content $FileBrowser.FileName | ConvertFrom-Json - Invoke-WPFPresets -preset $jsonFile -imported $true + Invoke-WPFPresets -preset $jsonFile -imported $true -CheckBox $checkbox } } function Invoke-WPFInstall { @@ -1010,8 +1294,10 @@ function Invoke-WPFPresets { param( $preset, - [bool]$imported = $false + [bool]$imported = $false, + $checkbox = "WPFTeaks" ) + if($imported -eq $true){ $CheckBoxesToCheck = $preset } @@ -1019,17 +1305,25 @@ function Invoke-WPFPresets { $CheckBoxesToCheck = $sync.configs.preset.$preset } - #Uncheck all - get-variable | Where-Object {$_.name -like "*tweaks*"} | ForEach-Object { - if ($psitem.value.gettype().name -eq "CheckBox"){ - $CheckBox = Get-Variable $psitem.Name - if ($CheckBoxesToCheck -contains $CheckBox.name){ - $checkbox.value.ischecked = $true + if($checkbox -eq "WPFTeaks"){ + $filter = Get-WinUtilVariables -Type Checkbox | Where-Object {$psitem -like "*tweaks*"} + $sync.GetEnumerator() | Where-Object {$psitem.Key -in $filter} | ForEach-Object { + if ($CheckBoxesToCheck -contains $PSItem.name){ + $sync.$($PSItem.name).ischecked = $true } - else{$checkbox.value.ischecked = $false} + else{$sync.$($PSItem.name).ischecked = $false} } } + if($checkbox -eq "WPFInstall"){ + $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.name).winget) -in $CheckBoxesToCheck){ + $sync.$($PSItem.name).ischecked = $true + } + else{$sync.$($PSItem.name).ischecked = $false} + } + } } function Invoke-WPFRunspace { @@ -1056,40 +1350,13 @@ function Invoke-WPFRunspace { $ArgumentList ) - #Configure max thread count for RunspacePool. - $maxthreads = [int]$env:NUMBER_OF_PROCESSORS - - #Create a new session state for parsing variables ie hashtable into our runspace. - $hashVars = New-object System.Management.Automation.Runspaces.SessionStateVariableEntry -ArgumentList 'sync',$sync,$Null - $InitialSessionState = [System.Management.Automation.Runspaces.InitialSessionState]::CreateDefault() - - #Add the variable to the RunspacePool sessionstate - $InitialSessionState.Variables.Add($hashVars) - - #Add functions - $functions = Get-ChildItem function:\ | Where-Object {$_.name -like "*winutil*" -or $_.name -like "*WPF*"} - foreach ($function in $functions){ - $functionDefinition = Get-Content function:\$($function.name) - $functionEntry = New-Object System.Management.Automation.Runspaces.SessionStateFunctionEntry -ArgumentList $($function.name), $functionDefinition - - # And add it to the iss object - $initialSessionState.Commands.Add($functionEntry) - } - - #Create our runspace pool. We are entering three parameters here min thread count, max thread count and host machine of where these runspaces should be made. - $script:runspace = [runspacefactory]::CreateRunspacePool(1,$maxthreads,$InitialSessionState, $Host) - - #Crate a PowerShell instance. $script:powershell = [powershell]::Create() - #Open a RunspacePool instance. - $script:runspace.Open() - #Add Scriptblock and Arguments to runspace $script:powershell.AddScript($ScriptBlock) $script:powershell.AddArgument($ArgumentList) - $script:powershell.RunspacePool = $script:runspace + $script:powershell.RunspacePool = $sync.runspace #Run our RunspacePool. $script:handle = $script:powershell.BeginInvoke() @@ -1099,11 +1366,44 @@ function Invoke-WPFRunspace { { $script:powershell.EndInvoke($script:handle) $script:powershell.Dispose() - $script:runspace.Dispose() - $script:runspace.Close() + $sync.runspace.Dispose() + $sync.runspace.Close() [System.GC]::Collect() } } +function Invoke-WPFShortcut { + <# + + .DESCRIPTION + Creates a shortcut + + #> + param($ShortcutToAdd) + + Switch ($ShortcutToAdd) { + "WinUtil" { + $SourceExe = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" + $IRM = 'irm https://christitus.com/win | iex' + $Powershell = '-ExecutionPolicy Bypass -Command "Start-Process powershell.exe -verb runas -ArgumentList' + $ArgumentsToSourceExe = "$powershell '$IRM'" + $DestinationName = "WinUtil.lnk" + } + } + + $FileBrowser = New-Object System.Windows.Forms.SaveFileDialog + $FileBrowser.InitialDirectory = [Environment]::GetFolderPath('Desktop') + $FileBrowser.Filter = "Shortcut Files (*.lnk)|*.lnk" + $FileBrowser.FileName = $DestinationName + $FileBrowser.ShowDialog() | Out-Null + + $WshShell = New-Object -comObject WScript.Shell + $Shortcut = $WshShell.CreateShortcut($FileBrowser.FileName) + $Shortcut.TargetPath = $SourceExe + $Shortcut.Arguments = $ArgumentsToSourceExe + $Shortcut.Save() + + Write-Host "Shortcut for $ShortcutToAdd has been saved to $($FileBrowser.FileName)" +} function Invoke-WPFTab { <# @@ -1114,37 +1414,43 @@ function Invoke-WPFTab { #> Param ($ClickedTab) - $Tabs = Get-Variable WPFTab?BT - $TabNav = Get-Variable WPFTabNav + $Tabs = Get-WinUtilVariables | Where-Object {$psitem -like "WPFTab?BT"} + $TabNav = Get-WinUtilVariables | Where-Object {$psitem -like "WPFTabNav"} $x = [int]($ClickedTab -replace "WPFTab","" -replace "BT","") - 1 0..($Tabs.Count -1 ) | ForEach-Object { if ($x -eq $psitem){ - $TabNav.value.Items[$psitem].IsSelected = $true + $sync.$TabNav.Items[$psitem].IsSelected = $true } else{ - $TabNav.value.Items[$psitem].IsSelected = $false + $sync.$TabNav.Items[$psitem].IsSelected = $false } } } function Invoke-WPFtweaksbutton { <# - - .DESCRIPTION - PlaceHolder - - #> + + .DESCRIPTION + PlaceHolder + + #> if($sync.ProcessRunning){ $msg = "Install process is currently running." [System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning) return -} + } $Tweaks = Get-WinUtilCheckBoxes -Group "WPFTweaks" - Set-WinUtilDNS -DNSProvider $WPFchangedns.text + Set-WinUtilDNS -DNSProvider $sync["WPFchangedns"].text + + if ($tweaks.count -eq 0 -and $sync["WPFchangedns"].text -eq "Default"){ + $msg = "Please check the tweaks you wish to perform." + [System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning) + return + } Invoke-WPFRunspace -ArgumentList $Tweaks -ScriptBlock { param($Tweaks) @@ -1211,30 +1517,36 @@ function Invoke-WPFundoall { [System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning) return } + + $Tweaks = Get-WinUtilCheckBoxes -Group "WPFTweaks" + + if ($tweaks.count -eq 0){ + $msg = "Please check the tweaks you wish to undo." + [System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning) + return + } - $Tweaks = Get-WinUtilCheckBoxes -Group "WPFTweaks" - - Invoke-WPFRunspace -ArgumentList $Tweaks -ScriptBlock { + Invoke-WPFRunspace -ArgumentList $Tweaks -ScriptBlock { param($Tweaks) - + $sync.ProcessRunning = $true - + Foreach ($tweak in $tweaks){ Invoke-WinUtilTweaks $tweak -undo $true } - + $sync.ProcessRunning = $false Write-Host "==================================" Write-Host "--- Undo Tweaks are Finished ---" Write-Host "==================================" - + $ButtonType = [System.Windows.MessageBoxButton]::OK $MessageboxTitle = "Tweaks are Finished " $Messageboxbody = ("Done") $MessageIcon = [System.Windows.MessageBoxImage]::Information - + [System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon) - } + } <# @@ -1388,6 +1700,64 @@ function Invoke-WPFundoall { Write-Host "=================================" #> } +function Invoke-WPFUnInstall { + <# + + .DESCRIPTION + PlaceHolder + + #> + + if($sync.ProcessRunning){ + $msg = "Install process is currently running." + [System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning) + return + } + + $WingetInstall = Get-WinUtilCheckBoxes -Group "WPFInstall" + + if ($wingetinstall.Count -eq 0) { + $WarningMsg = "Please select the program(s) to install" + [System.Windows.MessageBox]::Show($WarningMsg, $AppTitle, [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning) + return + } + + $ButtonType = [System.Windows.MessageBoxButton]::YesNo + $MessageboxTitle = "Are you sure?" + $Messageboxbody = ("This will uninstall the following applications `n $WingetInstall") + $MessageIcon = [System.Windows.MessageBoxImage]::Information + + $confirm = [System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon) + + if($confirm -eq "No"){return} + + Invoke-WPFRunspace -ArgumentList $WingetInstall -scriptblock { + param($WingetInstall) + try{ + $sync.ProcessRunning = $true + + # Install all winget programs in new window + Install-WinUtilProgramWinget -ProgramsToInstall $WingetInstall -Manage "Uninstalling" + + $ButtonType = [System.Windows.MessageBoxButton]::OK + $MessageboxTitle = "Uninstalls are Finished " + $Messageboxbody = ("Done") + $MessageIcon = [System.Windows.MessageBoxImage]::Information + + [System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon) + + Write-Host "===========================================" + Write-Host "-- Uninstalls have finished ---" + Write-Host "===========================================" + } + Catch { + Write-Host "===========================================" + Write-Host "-- Winget failed to install ---" + Write-Host "===========================================" + } + $sync.ProcessRunning = $False + } +} function Invoke-WPFUpdatesdefault { <# @@ -1531,14 +1901,14 @@ $inputXML = ' - - - - - + + @@ -1579,7 +1949,7 @@ $inputXML = ' - @@ -1590,9 +1960,9 @@ $inputXML = ' - + - + @@ -1601,14 +1971,14 @@ $inputXML = ' - -