将目录添加到 Windows 中的 PATH 环境变量 [英] Adding a directory to the PATH environment variable in Windows

查看:72
本文介绍了将目录添加到 Windows 中的 PATH 环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 C:xamppphp 添加到我在 Windows 中的系统 PATH 环境变量中.

I am trying to add C:xamppphp to my system PATH environment variable in Windows.

我已经使用环境变量对话框添加了它.

I have already added it using the Environment Variables dialog box.

但是当我在控制台中输入时:

But when I type into my console:

C:>path

它不显示新的 C:xamppphp 目录:

it doesn't show the new C:xamppphp directory:

PATH=D:Program FilesAutodeskMaya2008in;C:Ruby192in;C:WINDOWSsystem32;C:WINDOWS;
C:WINDOWSSystem32Wbem;C:PROGRA~1DISKEE~2DISKEE~1;c:Program FilesMicrosoft SQL
Server90Toolsinn;C:Program FilesQuickTimeQTSystem;D:Program FilesTortoiseSVNin
;D:Program FilesBazaar;C:Program FilesAndroidandroid-sdk	ools;D:Program Files
Microsoft Visual StudioCommonToolsWinNT;D:Program FilesMicrosoft Visual StudioCommon
MSDev98Bin;D:Program FilesMicrosoft Visual StudioCommonTools;D:Program Files
Microsoft Visual StudioVC98in

我有两个问题:

  1. 为什么会这样?是不是我做错了什么?
  2. 此外,如何使用控制台(并以编程方式使用批处理文件)将目录添加到我的 PATH 变量中?

推荐答案

这只会修改注册表.现有流程不会使用这些值.如果一个新进程在此更改之后启动,并且没有从其父进程继承旧环境,它就会这样做.

This only modifies the registry. An existing process won't use these values. A new process will do so if it is started after this change and doesn't inherit the old environment from its parent.

您没有指定如何启动控制台会话.确保这一点的最佳方法是退出命令外壳并再次运行它.然后它应该继承更新的 PATH 环境变量.

You didn't specify how you started the console session. The best way to ensure this is to exit the command shell and run it again. It should then inherit the updated PATH environment variable.

这篇关于将目录添加到 Windows 中的 PATH 环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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