Environment variable - Path

Welcome Forums General PowerShell Q&A Environment variable - Path

This topic contains 3 replies, has 2 voices, and was last updated by

 
Participant
3 years, 2 months ago.

  • Author
    Posts
  • #31003

    Participant
    Points: 0
    Rank: Member

    Hello good folks.

    Would anyone be so kind and help me with setting or appending a parth variable in Powershell?

    Is there an elegant way to do it other than to use some function which edits a registry value? By elegant way I mean some new way in Powershell v5. 🙂

    Thank you very much.

  • #31004

    Participant
    Points: 0
    Rank: Member

    Maybe you could use the .NET method SetEnvironmentVariable?

    Call it from PowerShell:
    [System.Environment]::SetEnvironmentVariable()

    https://msdn.microsoft.com/en-us/library/z46c489x(v=vs.110).aspx

    /Alexander

  • #31076

    Participant
    Points: 0
    Rank: Member

    Great suggestion,

    thank you.

  • #31618

    Participant
    Points: 0
    Rank: Member

    $Env:Path = $Env:Path + ";C:\SomeFolder

    I found this solution also, if anybody ever needs it.

The topic ‘Environment variable - Path’ is closed to new replies.