mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-04-03 14:06:27 +00:00
Add ability to export/import settings configuration (#522)
This commit is contained in:
@@ -13,6 +13,7 @@ param (
|
||||
[switch]$RunDefaults,
|
||||
[switch]$RunDefaultsLite,
|
||||
[switch]$RunSavedSettings,
|
||||
[string]$Config,
|
||||
[string]$Apps,
|
||||
[string]$AppRemovalTarget,
|
||||
[switch]$RemoveApps,
|
||||
@@ -119,9 +120,10 @@ $script:AboutWindowSchema = "$PSScriptRoot/Schemas/AboutWindow.xaml"
|
||||
$script:ApplyChangesWindowSchema = "$PSScriptRoot/Schemas/ApplyChangesWindow.xaml"
|
||||
$script:SharedStylesSchema = "$PSScriptRoot/Schemas/SharedStyles.xaml"
|
||||
$script:BubbleHintSchema = "$PSScriptRoot/Schemas/BubbleHint.xaml"
|
||||
$script:ImportExportConfigSchema = "$PSScriptRoot/Schemas/ImportExportConfigWindow.xaml"
|
||||
$script:LoadAppsDetailsScriptPath = "$PSScriptRoot/Scripts/FileIO/LoadAppsDetailsFromJson.ps1"
|
||||
|
||||
$script:ControlParams = 'WhatIf', 'Confirm', 'Verbose', 'Debug', 'LogPath', 'Silent', 'Sysprep', 'User', 'NoRestartExplorer', 'RunDefaults', 'RunDefaultsLite', 'RunSavedSettings', 'RunAppsListGenerator', 'CLI', 'AppRemovalTarget'
|
||||
$script:ControlParams = 'WhatIf', 'Confirm', 'Verbose', 'Debug', 'LogPath', 'Silent', 'Sysprep', 'User', 'NoRestartExplorer', 'RunDefaults', 'RunDefaultsLite', 'RunSavedSettings', 'Config', 'RunAppsListGenerator', 'CLI', 'AppRemovalTarget'
|
||||
|
||||
# Script-level variables for GUI elements
|
||||
$script:GuiWindow = $null
|
||||
@@ -249,6 +251,7 @@ if (-not $script:WingetInstalled -and -not $Silent) {
|
||||
|
||||
# File I/O functions
|
||||
. "$PSScriptRoot/Scripts/FileIO/LoadJsonFile.ps1"
|
||||
. "$PSScriptRoot/Scripts/FileIO/SaveToFile.ps1"
|
||||
. "$PSScriptRoot/Scripts/FileIO/SaveSettings.ps1"
|
||||
. "$PSScriptRoot/Scripts/FileIO/LoadSettings.ps1"
|
||||
. "$PSScriptRoot/Scripts/FileIO/SaveCustomAppsListToFile.ps1"
|
||||
@@ -263,6 +266,7 @@ if (-not $script:WingetInstalled -and -not $Silent) {
|
||||
. "$PSScriptRoot/Scripts/GUI/AttachShiftClickBehavior.ps1"
|
||||
. "$PSScriptRoot/Scripts/GUI/ApplySettingsToUiControls.ps1"
|
||||
. "$PSScriptRoot/Scripts/GUI/Show-MessageBox.ps1"
|
||||
. "$PSScriptRoot/Scripts/GUI/Show-ConfigWindow.ps1"
|
||||
. "$PSScriptRoot/Scripts/GUI/Show-ApplyModal.ps1"
|
||||
. "$PSScriptRoot/Scripts/GUI/Show-AppSelectionWindow.ps1"
|
||||
. "$PSScriptRoot/Scripts/GUI/Show-MainWindow.ps1"
|
||||
@@ -275,6 +279,7 @@ if (-not $script:WingetInstalled -and -not $Silent) {
|
||||
. "$PSScriptRoot/Scripts/Helpers/CheckModernStandbySupport.ps1"
|
||||
. "$PSScriptRoot/Scripts/Helpers/GenerateAppsList.ps1"
|
||||
. "$PSScriptRoot/Scripts/Helpers/GetFriendlyTargetUserName.ps1"
|
||||
. "$PSScriptRoot/Scripts/Helpers/ImportConfigToParams.ps1"
|
||||
. "$PSScriptRoot/Scripts/Helpers/GetTargetUserForAppRemoval.ps1"
|
||||
. "$PSScriptRoot/Scripts/Helpers/GetUserDirectory.ps1"
|
||||
. "$PSScriptRoot/Scripts/Helpers/GetUserName.ps1"
|
||||
@@ -371,7 +376,7 @@ if ($RunAppsListGenerator) {
|
||||
}
|
||||
|
||||
# Change script execution based on provided parameters or user input
|
||||
if ((-not $script:Params.Count) -or $RunDefaults -or $RunDefaultsLite -or $RunSavedSettings -or ($controlParamsCount -eq $script:Params.Count)) {
|
||||
if ((-not $script:Params.Count) -or $RunDefaults -or $RunDefaultsLite -or $RunSavedSettings -or $Config -or ($controlParamsCount -eq $script:Params.Count)) {
|
||||
if ($RunDefaults -or $RunDefaultsLite) {
|
||||
ShowCLIDefaultModeOptions
|
||||
}
|
||||
@@ -384,6 +389,21 @@ if ((-not $script:Params.Count) -or $RunDefaults -or $RunDefaultsLite -or $RunSa
|
||||
|
||||
ShowCLILastUsedSettings
|
||||
}
|
||||
elseif ($Config) {
|
||||
try {
|
||||
ImportConfigToParams -ConfigPath $Config -CurrentBuild $WinVersion -ExpectedVersion '1.0'
|
||||
}
|
||||
catch {
|
||||
Write-Error "$_"
|
||||
AwaitKeyToExit
|
||||
}
|
||||
|
||||
if (-not $Silent) {
|
||||
PrintHeader 'Custom Mode'
|
||||
PrintPendingChanges
|
||||
PrintHeader 'Custom Mode'
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($CLI) {
|
||||
$Mode = ShowCLIMenuOptions
|
||||
|
||||
Reference in New Issue
Block a user