mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-11-26 07:26:18 +01:00
fix: streamline cleanup process in Get.ps1 by removing config exclusion (#889)
This exclusion is no longer required as user files are stored in %LOCALAPPDATA%\Win11Debloat Logs and Backups are still excluded for cases where the script is run in SYSTEM context
This commit is contained in:
+4
-37
@@ -194,31 +194,12 @@ if ($expectedArchiveHash -and -not (Test-FileHashMatch $tempArchivePath $expecte
|
|||||||
Exit 1
|
Exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Remove old script folder if it exists, but keep configs, logs and backups
|
# Remove old script files if they exist, but keep logs and backups
|
||||||
if (Test-Path $tempWorkPath) {
|
if (Test-Path $tempWorkPath) {
|
||||||
Write-Output ""
|
Write-Output ""
|
||||||
Write-Output "> Cleaning up old script files..."
|
Write-Output "> Cleaning up old script files..."
|
||||||
|
|
||||||
Get-ChildItem -Path $tempWorkPath -Exclude Config,Logs,Backups | Remove-Item -Recurse -Force
|
Get-ChildItem -Path $tempWorkPath -Exclude Logs,Backups | Remove-Item -Recurse -Force
|
||||||
}
|
|
||||||
|
|
||||||
$configDir = Join-Path $tempWorkPath 'Config'
|
|
||||||
$backupDir = Join-Path $tempWorkPath 'ConfigOld'
|
|
||||||
|
|
||||||
# Temporarily move existing config files if they exist to prevent them from being overwritten by the new script files, will be moved back after the new script is unpacked
|
|
||||||
if (Test-Path "$configDir") {
|
|
||||||
Write-Output ""
|
|
||||||
Write-Output "> Backing up existing config files..."
|
|
||||||
|
|
||||||
New-Item -ItemType Directory -Path "$backupDir" -Force | Out-Null
|
|
||||||
|
|
||||||
$filesToKeep = @(
|
|
||||||
'LastUsedSettings.json'
|
|
||||||
)
|
|
||||||
|
|
||||||
Get-ChildItem -Path "$configDir" -Recurse | Where-Object { $_.Name -in $filesToKeep } | Move-Item -Destination "$backupDir"
|
|
||||||
|
|
||||||
Remove-Item "$configDir" -Recurse -Force
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Output ""
|
Write-Output ""
|
||||||
@@ -233,19 +214,6 @@ Remove-Item $tempArchivePath
|
|||||||
# Move files
|
# Move files
|
||||||
Get-ChildItem -Path (Join-Path $tempWorkPath '*Win11Debloat-*') -Recurse | Move-Item -Destination $tempWorkPath
|
Get-ChildItem -Path (Join-Path $tempWorkPath '*Win11Debloat-*') -Recurse | Move-Item -Destination $tempWorkPath
|
||||||
|
|
||||||
# Add existing config files back to Config folder
|
|
||||||
if (Test-Path "$backupDir") {
|
|
||||||
if (-not (Test-Path "$configDir")) {
|
|
||||||
New-Item -ItemType Directory -Path "$configDir" -Force | Out-Null
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Output ""
|
|
||||||
Write-Output "> Restoring existing config files..."
|
|
||||||
|
|
||||||
Get-ChildItem -Path "$backupDir" -Recurse | Move-Item -Destination "$configDir"
|
|
||||||
Remove-Item "$backupDir" -Recurse -Force
|
|
||||||
}
|
|
||||||
|
|
||||||
# Quote a value so it survives CommandLineToArgvW parsing in the child process: double any backslash run that
|
# Quote a value so it survives CommandLineToArgvW parsing in the child process: double any backslash run that
|
||||||
# precedes a quote or the closing quote, and escape embedded quotes, before wrapping the value in quotes.
|
# precedes a quote or the closing quote, and escape embedded quotes, before wrapping the value in quotes.
|
||||||
function Format-LauncherArg([string]$Value) {
|
function Format-LauncherArg([string]$Value) {
|
||||||
@@ -308,13 +276,12 @@ if ($null -ne $debloatProcess) {
|
|||||||
$exitCode = $debloatProcess.ExitCode
|
$exitCode = $debloatProcess.ExitCode
|
||||||
}
|
}
|
||||||
|
|
||||||
# Remove all remaining script files, except for configs, logs and backups
|
# Remove all remaining script files, except for logs and backups
|
||||||
if (Test-Path $tempWorkPath) {
|
if (Test-Path $tempWorkPath) {
|
||||||
Write-Output ""
|
Write-Output ""
|
||||||
Write-Output "> Cleaning up..."
|
Write-Output "> Cleaning up..."
|
||||||
|
|
||||||
# Cleanup, remove Win11Debloat directory
|
Get-ChildItem -Path $tempWorkPath -Exclude Logs,Backups | Remove-Item -Recurse -Force
|
||||||
Get-ChildItem -Path $tempWorkPath -Exclude Config,Logs,Backups | Remove-Item -Recurse -Force
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Output ""
|
Write-Output ""
|
||||||
|
|||||||
Reference in New Issue
Block a user