Setting Windows PowerShell environment variables

前端 未结 18 1923
日久生厌
日久生厌 2020-11-22 11:03

I have found out that setting the PATH environment variable affects only the old command prompt. PowerShell seems to have different environment settings. How do I change the

18条回答
  •  执笔经年
    2020-11-22 11:36

    Within PowerShell, one can navigate to the environment variable directory by typing:

    Set-Location Env:
    

    This will bring you to the Env:> directory. From within this directory:

    To see all environment variables, type:

    Env:\> Get-ChildItem
    

    To see a specific environment variable, type:

    Env:\> $Env:, e.g. $Env:Path
    

    To set an environment variable, type:

    Env:\> $Env: = "", e.g. $Env:Path="C:\Users\"
    

    To remove an environment variable, type:

    Env:\> remove-item Env:, e.g. remove-item Env:SECRET_KEY
    

    More information is in About Environment Variables.

提交回复
热议问题