1
votes

When i am trying to echo the system path variable it is showing the same thing twice.

My system path variable:

C:\oraclexe\app\oracle\product\10.2.0\server\bin;C:\Program Files (x86)\PC Connectivity Solution\;C:\Program Files\Common Files\MicrosoftShared\Windows Live;C:\Program Files (x86)\CommonFiles\MicrosoftShared\WindowsLive;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Dell\DW WLAN Card;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\Program Files (x86)\Windows Live\Shared;

And when i echo it on cmd echo %Path% it displays this

C:\oraclexe\app\oracle\product\10.2.0\server\bin;C:\Program Files (x86)\PC Connectivity Solution\;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\WindowsLive;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Dell\DW WLAN Card;C:\ProgramFiles\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\Program Files(x86)\WindowsLive\Shared;C:\oraclexe\app\oracle\product\10.2.0\server\bin;C:\Program Files (x86)\PC ConnectivitySolution\;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\System32\WindowsPowerShell\v1.0\;C:\Program Files\Dell\DW WLAN Card;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\Program Files (x86)\WindowsLive\Shared;F:\Java\jdk1.6.0_38\bin\

Can anybody help why is it displaying same values twice? And is there side effects of this?

P.S: I have created a local Path variable as %Path%F:\Java\jdk1.6.0_38\bin\

2
It may be that you copied the path data twice, how are you exactly creating the %Path% variable?Rafael
Its Path = %Path%;F:\Java\jdk1.6.0_38\bin\Abhishek kumar

2 Answers

1
votes

Sometime between WindosXP and Windows7 the interpretation of the user level PATH variable changed. Now it automatically appends the path to the system defined path rather than replacing it the way it previously did.

Thus your local path ends up being %PATH%;%PATH%;F:\Java\jdk1.6.0_36\bin

The good news is it works -- you find the desired files. The bad news is it takes slighly longer to find your java bin files.

Edit: The annoying news is that you can no longer override system defined commands. Defining user level PATH as mybin;%PATH% does not produce the desired results.

0
votes

If you're doing this in the console you can create a batch script with the following content:

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"

Which basically takes the Path value from the registry and add your path to it. Note that also there is a limit of around 1024 characters in the Path length if you set it in the console with the Set command, and this code workaround this limit.