Why is the Powershell Environment PATH different to the System Environment PATH?

后端 未结 2 961
情歌与酒
情歌与酒 2021-02-02 07:52

I\'m having this weird situation :

My user\'s and system\'s PATH variable is different than the PATH in powershell.

When I do :

PS C:\\$env:path         


        
2条回答
  •  北荒
    北荒 (楼主)
    2021-02-02 08:39

    The change might be "delayed", so try one or more of these solutions:

    • Log off and on again;
    • Task Manager > Restart "Windows Explorer" (explorer.exe)
    • Restart your launcher app (launchy, SlickRun, etc)
    • Reboot

    Explanation:
    Powershell will inherit the environment of the process that launched it (which depends on how you launch it). This is usually the interactive shell (explorer.exe). When you modify the environment from computer properties, you modify the environment of explorer.exe, so if you launch powershell from explorer.exe, (for example from the start menu) you should see the new environment.

    However, if you launch it from something else (say a cmd.exe shell that you already had opened), then you won't since that process was launched under the old environment.

    In other words: be careful how you are launching things.

提交回复
热议问题