I copied a powershell.exe
file for creating a custom terminal profile but the $PROFILE
environment variable remains unchanged. I like it to change when I run the copied executable. I have already tried setting $PROFILE = "C:\New\Path\to\Profile"
but this does nothing.
I copied a powershell.exe
file for creating a custom terminal profile but the $PROFILE
environment variable remains unchanged. I like it to change when I run the copied executable. I have already tried setting $PROFILE = "C:\New\Path\to\Profile"
but this does nothing.
1 Answer
Reset to default 1The value(s) of the automatic $PROFILE
variable can not be changed (meaningfully).[1]
Instead of creating a copy of powershell.exe
(the Windows PowerShell CLI) in a different location, use the original along with CLI parameters that emulate loading a profile file from a custom location:
powershell.exe -NoProfile -NoExit -File C:\New\Path\to\Profile.ps1
Note: By using -NoProfile
, none of the - potentially multiple - profile files will be loaded.
[1] Except indirectly, if you change the location of the well-known Documents folders, which has far-reaching consequences, however. See this answer for details.
The fact that PowerShell even technically allows you to assign a new value to the $PROFILE
variable - which, however, has no effect (leaving aside that, conceptually, making this assignment in-session, after the session has already started, would be too late) - should be considered a bug; see this answer.