为什么Powershell环境PATH与系统环境PATH不同? [英] Why is the Powershell Environment PATH different to the System Environment PATH?

查看:75
本文介绍了为什么Powershell环境PATH与系统环境PATH不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到这种奇怪的情况:

I'm having this weird situation :

我的用户和系统的PATH变量与powershell中的PATH不同.

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

当我这样做时:

PS C:\$env:path
C:\Windows\System32\WindowsPowerShell\v1.0\;c:\oldpath

但是这是不正确的,它看起来像卡在了我的系统的某个旧PATH变量上,所以我对它所做的所有修改都不改变该变量(我在每次测试更改后都会重新启动)

However this is not correct, it looks like it stuck on some old PATH variable of my system, so none of the udpates I've done on it didn't change this variable (I do restart after every change to test).

为什么会这样?我是否仅需要为powershell设置PATH变量?

Why is this happening? Do I have to set a PATH variable just for powershell?

推荐答案

更改可能已延迟",因此请尝试以下一种或多种解决方案:

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

  • 注销并再次登录
  • 任务管理器> 重新启动"Windows资源管理器" (explorer.exe)
  • 重新启动启动器应用(启动,SlickRun等)
  • 重新启动
  • Log off and on again;
  • Task Manager > Restart "Windows Explorer" (explorer.exe)
  • Restart your launcher app (launchy, SlickRun, etc)
  • Reboot

说明:
Powershell将继承启动它的进程的环境(取决于您启动它的方式).这通常是交互式外壳程序(explorer.exe).从计算机属性修改环境时,将修改explorer.exe的环境,因此,如果从explorer.exe启动powershell,例如从开始"菜单启动,则应该看到新环境.

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.

但是,如果您从其他地方启动它(例如,您已经打开的cmd.exe shell),那么您将不会继续,因为该过程是在旧环境下启动的.

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.

这篇关于为什么Powershell环境PATH与系统环境PATH不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆