Skip to content

Commit

Permalink
refactor: make env setting less hardcoded
Browse files Browse the repository at this point in the history
  • Loading branch information
he3als committed Feb 8, 2024
1 parent c0d0601 commit 047402c
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/playbook/Configuration/atlas/start.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,20 @@ actions:
- !powerShell:
wait: true
command: >-
[Environment]::SetEnvironmentVariable('Path', $env:Path +
""";$env:windir\AtlasModules;$env:windir\AtlasModules\Apps;$env:windir\AtlasModules\Other;$env:windir\AtlasModules\Tools;%windir%\AtlasModules\Scripts""",
[System.EnvironmentVariableTarget]::Machine);
$modulesPath = """$env:windir\AtlasModules""";
[Environment]::SetEnvironmentVariable('PSModulePath', $env:PSModulePath +
""";$env:windir\AtlasModules\Scripts\Modules""",
[System.EnvironmentVariableTarget]::Machine)
function AddToVar($env, $value) {
$a = [IO.Path]::PathSeparator;
$b = [System.EnvironmentVariableTarget]::Machine;
$c = [Environment]::GetEnvironmentVariables($b);
[Environment]::SetEnvironmentVariable($env,
("""$($c.'Path');$value""" -replace ';',"""$a"""),
$b);
};
AddToVar 'Path' """$modulesPath;$modulesPath\Apps;$modulesPath\Other;$modulesPath\Tools;$modulesPath\Scripts""";
AddToVar 'PSModulePath' """$modulesPath\Scripts\Modules""";
# Doesn't refresh the environment variables of TrustedUninstaller
# An alternative should be found, for now, exact paths are used
Expand Down

0 comments on commit 047402c

Please sign in to comment.