mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-06-11 02:56:32 +00:00
Clean up Get.ps1, Get-Dev.ps1
This commit is contained in:
@@ -133,12 +133,12 @@ catch {
|
|||||||
Exit
|
Exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Remove old script folder if it exists, but keep configs, logs and backups
|
||||||
|
if (Test-Path $tempWorkPath) {
|
||||||
Write-Output ""
|
Write-Output ""
|
||||||
Write-Output "> Cleaning up old Win11Debloat folder..."
|
Write-Output "> Cleaning up old Win11Debloat folder..."
|
||||||
|
|
||||||
# Remove old script folder if it exists, but keep config and log files
|
Get-ChildItem -Path $tempWorkPath -Exclude Config,Logs,Backups | Remove-Item -Recurse -Force
|
||||||
if (Test-Path $tempWorkPath) {
|
|
||||||
Get-ChildItem -Path $tempWorkPath -Exclude CustomAppsList,LastUsedSettings.json,Win11Debloat.log,Config,Logs,Backups | Remove-Item -Recurse -Force
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$configDir = Join-Path $tempWorkPath 'Config'
|
$configDir = Join-Path $tempWorkPath 'Config'
|
||||||
@@ -146,6 +146,9 @@ $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
|
# 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") {
|
if (Test-Path "$configDir") {
|
||||||
|
Write-Output ""
|
||||||
|
Write-Output "> Backing up existing config files..."
|
||||||
|
|
||||||
New-Item -ItemType Directory -Path "$backupDir" -Force | Out-Null
|
New-Item -ItemType Directory -Path "$backupDir" -Force | Out-Null
|
||||||
|
|
||||||
$filesToKeep = @(
|
$filesToKeep = @(
|
||||||
@@ -176,6 +179,9 @@ if (Test-Path "$backupDir") {
|
|||||||
New-Item -ItemType Directory -Path "$configDir" -Force | Out-Null
|
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"
|
Get-ChildItem -Path "$backupDir" -Recurse | Move-Item -Destination "$configDir"
|
||||||
Remove-Item "$backupDir" -Recurse -Force
|
Remove-Item "$backupDir" -Recurse -Force
|
||||||
}
|
}
|
||||||
@@ -216,13 +222,13 @@ if ($null -ne $debloatProcess) {
|
|||||||
$debloatProcess.WaitForExit()
|
$debloatProcess.WaitForExit()
|
||||||
}
|
}
|
||||||
|
|
||||||
# Remove all remaining script files, except for CustomAppsList and LastUsedSettings.json files
|
# Remove all remaining script files, except for configs, 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
|
# Cleanup, remove Win11Debloat directory
|
||||||
Get-ChildItem -Path $tempWorkPath -Exclude CustomAppsList,LastUsedSettings.json,Win11Debloat.log,Win11Debloat-Run.log,Config,Logs,Backups | Remove-Item -Recurse -Force
|
Get-ChildItem -Path $tempWorkPath -Exclude Config,Logs,Backups | Remove-Item -Recurse -Force
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Output ""
|
Write-Output ""
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ Expand-Archive $tempArchivePath $tempWorkPath
|
|||||||
Remove-Item $tempArchivePath
|
Remove-Item $tempArchivePath
|
||||||
|
|
||||||
# Move files
|
# Move files
|
||||||
Get-ChildItem -Path (Join-Path $tempWorkPath 'Raphire-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
|
# Add existing config files back to Config folder
|
||||||
if (Test-Path "$backupDir") {
|
if (Test-Path "$backupDir") {
|
||||||
|
|||||||
Reference in New Issue
Block a user