From 00d349e1623ceedbbe9cdba95fc57dc838baf68e Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Thu, 27 Jul 2023 02:28:37 +0200 Subject: [PATCH] Force creation of profile files --- scripts/Windows/Scripts/Context.ps1 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/Windows/Scripts/Context.ps1 b/scripts/Windows/Scripts/Context.ps1 index 2ecd02bb..32670ffa 100644 --- a/scripts/Windows/Scripts/Context.ps1 +++ b/scripts/Windows/Scripts/Context.ps1 @@ -46,7 +46,16 @@ class Context { $profileFiles = $profileFiles | ForEach-Object { Join-Path (Split-Path -Parent $_) "profile.d" "$category.ps1"; }; } - $profileFiles | ForEach-Object { Add-Content "C:\Users\Default\$_" "`n$statement"; }; + $profileFiles | ForEach-Object { + $dirName = Split-Path -Parent $_; + + if (-not (Test-Path -PathType Container $dirName)) { + New-Item -ItemType Directory $dirName; + } + + Add-Content -Force "C:\Users\Default\$_" "`n$statement"; + }; + Pop-Location; }