1

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 1

1

The 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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.