【问题标题】:Echoing path variable in windows displaying twice在窗口中回显路径变量显示两次
【发布时间】:2013-06-26 16:13:39
【问题描述】:

当我尝试回显系统路径变量时,它会显示两次相同的内容。

我的系统路径变量:

C:\oracle\app\oracle\product\10.2.0\server\bin;C:\Program Files (x86)\PC 连接解决方​​案\;C:\Program Files\Common 文件\MicrosoftShared\Windows Live;C:\Program 文件 (x86)\CommonFiles\MicrosoftShared\WindowsLive;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Dell\DW WLAN 卡;C:\Program Files\WIDCOMM\Bluetooth 软件\;C:\Program Files\WIDCOMM\Bluetooth 软件\syswow64;C:\Program Files (x86)\Windows Live\Shared;

当我在 cmd 上回显它时 echo %Path% 它显示这个

C:\oracle\app\oracle\product\10.2.0\server\bin;C:\Program Files (x86)\PC 连接解决方​​案\;C:\Program Files\Common 文件\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common 文件\微软 Shared\WindowsLive;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Dell\DW WLAN 卡;C:\ProgramFiles\WIDCOMM\Bluetooth 软件\;C:\Program Files\WIDCOMM\Bluetooth 软件\syswow64;C:\程序 文件(x86)\WindowsLive\Shared;C:\oraclexe\app\oracle\product\10.2.0\server\bin;C:\Program 文件 (x86)\PC ConnectivitySolution\;C:\Program Files\Common 文件\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common 文件\Microsoft 共享\Windows 直播;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\System32\WindowsPowerShell\v1.0\;C:\Program Files\Dell\DW WLAN 卡;C:\Program Files\WIDCOMM\Bluetooth 软件\;C:\Program Files\WIDCOMM\Bluetooth 软件\syswow64;C:\Program 文件 (x86)\WindowsLive\Shared;F:\Java\jdk1.6.0_38\bin\

谁能帮助它为什么显示两次相同的值?这样做有副作用吗?

P.S:我创建了一个本地 Path 变量作为 %Path%F:\Java\jdk1.6.0_38\bin\

【问题讨论】:

  • 可能是您复制了两次路径数据,您究竟是如何创建 %Path% 变量的?
  • 其路径 = %Path%;F:\Java\jdk1.6.0_38\bin\

标签: windows-7 environment-variables


【解决方案1】:

有时在WindosXP 和Windows7 之间,用户级PATH 变量的解释发生了变化。现在它会自动将路径附加到系统定义的路径,而不是像以前那样替换它。

因此,您的本地路径最终是 %PATH%;%PATH%;F:\Java\jdk1.6.0_36\bin

好消息是它有效——您可以找到所需的文件。坏消息是找到您的 java bin 文件需要更长的时间。

编辑:烦人的消息是您不能再覆盖系统定义的命令。将用户级 PATH 定义为 mybin;%PATH% 不会产生预期的结果。

【讨论】:

    【解决方案2】:

    如果您在控制台中执行此操作,您可以创建一个包含以下内容的批处理脚本:

    for /F "tokens=2* delims= " %%f IN ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Path ^| findstr /i path') do set OLD_SYSTEM_PATH=%%g
    reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Path /t REG_SZ /d "%OLD_SYSTEM_PATH%;F:\Java\jdk1.6.0_36\bin"
    

    这基本上从注册表中获取路径值并将您的路径添加到它。请注意,如果您在控制台中使用 Set 命令设置路径长度,则路径长度也有大约 1024 个字符的限制,此代码可解决此限制。

    【讨论】:

    • 我是通过控制面板设置->EnvironmentVariables
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多