From a33e3ade050a11b33302557d4dbbccb5bf5dee96 Mon Sep 17 00:00:00 2001 From: Jeffrey <9938813+Raphire@users.noreply.github.com> Date: Thu, 22 Oct 2026 21:12:16 +0200 Subject: [PATCH] fix: handle missing LOCALAPPDATA in user data path assignment (#852) --- Win11Debloat.ps1 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Win11Debloat.ps1 b/Win11Debloat.ps1 index bd5db98..2145737 100644 --- a/Win11Debloat.ps1 +++ b/Win11Debloat.ps1 @@ -174,7 +174,13 @@ if (-not $isAdmin) { # Define script-level variables & paths $script:Version = "2026.08.24" $configPath = Join-Path $PSScriptRoot 'Config' -$script:UserDataPath = Join-Path $env:LOCALAPPDATA 'Win11Debloat' +# Deployment environments such as SCCM task sequences may not define LOCALAPPDATA. +if ([string]::IsNullOrWhiteSpace($env:LOCALAPPDATA)) { + $script:UserDataPath = $PSScriptRoot +} +else { + $script:UserDataPath = Join-Path $env:LOCALAPPDATA 'Win11Debloat' +} $script:LogsPath = Join-Path $script:UserDataPath 'Logs' $schemasPath = Join-Path $PSScriptRoot 'Schemas' $scriptsPath = Join-Path $PSScriptRoot 'Scripts'