mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-10-17 11:12:01 +00:00
feat: refactor file paths to use %LOCALAPPDATA% for user data and logs
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
.DESCRIPTION
|
||||
Resolves selected and undo features from the provided keys, captures their
|
||||
registry state, and saves the result as a JSON file in the Backups/ folder.
|
||||
registry state, and saves the result under %LOCALAPPDATA%\Win11Debloat\Backups.
|
||||
Returns the file path on success, $null if no registry-backed features exist.
|
||||
|
||||
.PARAMETER ActionableKeys
|
||||
@@ -28,13 +28,8 @@ function New-RegistrySettingsBackup {
|
||||
}
|
||||
|
||||
$timestamp = Get-Date
|
||||
$backupDirectory = $script:RegistryBackupsPath
|
||||
if (-not (Test-Path $backupDirectory)) {
|
||||
New-Item -ItemType Directory -Path $backupDirectory -Force | Out-Null
|
||||
}
|
||||
|
||||
$backupFileName = 'Win11Debloat-RegistryBackup-{0}.json' -f $timestamp.ToString('yyyyMMdd_HHmmss')
|
||||
$backupFilePath = Join-Path $backupDirectory $backupFileName
|
||||
$backupFilePath = Join-Path $script:RegistryBackupsPath $backupFileName
|
||||
|
||||
$backupConfig = Get-RegistryBackupPayload -SelectedFeatures $selectedFeatures -UndoFeatures $undoFeatures -CreatedAt $timestamp
|
||||
if (-not (Save-ToFile -Config $backupConfig -FilePath $backupFilePath -MaxDepth 25)) {
|
||||
|
||||
@@ -27,6 +27,8 @@ function Save-ToFile {
|
||||
)
|
||||
|
||||
try {
|
||||
$directory = Split-Path -Parent $FilePath
|
||||
if ($directory) { [void][System.IO.Directory]::CreateDirectory($directory) }
|
||||
$Config | ConvertTo-Json -Depth $MaxDepth | Set-Content -Path $FilePath -Encoding UTF8 -ErrorAction Stop
|
||||
return $true
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ function Show-MainWindow {
|
||||
$menuReportBug.Add_Click({ Start-Process "https://github.com/Raphire/Win11Debloat/issues" })
|
||||
|
||||
$menuLogs.Add_Click({
|
||||
$logsFolder = Join-Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) 'Logs'
|
||||
$logsFolder = Split-Path -Parent $script:DefaultLogPath
|
||||
if (Test-Path $logsFolder) {
|
||||
Start-Process "explorer.exe" -ArgumentList $logsFolder
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user