Strange PATH issue in Windows 7 - goes null after being set

JasonXA

I have some sort of a problem with the PATH system variable. Since I use a lot of cmd apps and scripts I've added a lot to it. But the string's length is not the issue. I've worked around this limitation.

Advanced System Properties is the only application which I've noticed to initialize the PATH variable properly after an edit. If I edit registry manually, apps don't use the updated version of the PATH. So I have to use it or keep loggin on and off.

However, lately, after setting some values of PATH in that app, it always ends up being (null), even if it's the same string. Once I press OK, it goes dark. Registry entries are still there. I have to log-off or restart for the PATH to get populated with whatever is in its registry entry.

I've even trimmed it down to %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem Still, PATH=(null) and %windir% is dead.

Leave it alone, it works.

Edit it, nope. Not until I restart.

So, any ideas?... about why advanced system properties is behaving like this when updating the system variables. I believe this is the issue, since it's an initializing app and since on a clean restart everything works.

JasonXA

After some tries, I managed to come up with some basic Environment variable rules when working with command line tools and PATH.

1st. A) Length: No Variable should be longer than 2047. If there are variables longer than 2047, variables after them won't expand, won't show up and Path will become null, PATH=(null).

It's very unlikely to arrive here but as it happens, I was in this situation and this was the main issue, however, this limitation is tricky, because it comes in effect only after editing the Environment variables in the editor (Advanced System Settings / SystemPropertiesAdvanced.exe). It will not have any negative effect if the variables are left unedited after booting up, but, if child explorer are executed for browsing in separate process, the command consoles opened from those explorer windows will be affected.

1st. B) Which Length? It doesn't matter. If a variable is used in Command console it is limited either way to 2047 chars of value, expanded or declared.

Declared:

ex:
x = %variable001%;%variable002%;%variable003%;...;%variable146%;%variable147%

Won't work.
Up to 146, it will because x won't be longer than 2047.
But 147 will kill it. Length of %variable???%; x 147 = 2058.

Expanded:

ex:
x001 = C:\Program Files
x002 = C:\Program Files
x003 = C:\Program Files
...
x120 = C:\Program Files
x121 = C:\Program Files

z = %x001%;%x002%;%x003%;...;%x120%;%x121%;

Will work but will show only up to x120 and part of x121.
Length of C:\Program Files; x 120 = 2040 + C:\Prog of x121

2nd. Place: Expandable variables don't expand recursively. In registry they are of type REG_EXPAND_SZ, in Environment variables editor they are set if the % character is typed in. If there are such variables declared, this needs to be done so that they are initialized before PATH. Normal variables don't have this issue. They can be declared after PATH and their values will still show.

ex:
a = C:\Windows
b (exp) = %SystemRoot%
c (exp) = %a%;%b%;%x%;%y%
x = C:\Windows
y (exp) = %SystemRoot%
z (exp) = %a%;%b%;%x%;%y%

echo %c% will output C:\Windows;C:\Windows;C:\Windows;%y%
                          a          b          x      y
echo %y% will output C:\Windows
echo %z% will output C:\Windows;C:\Windows;C:\Windows;C:\Windows
                          a          b          x          y

Variable y was not expanded inside c because it was declared after c, but was expanded in c's clone, z.

So, to keep PATH alive and well, there has to be no lengthy variable before it and it can contain expandable variables as long as they are declared before Path in an alphabetical hierarchy (from a to o). All while keeping a final value length below 2048.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Strange copy and paste issue across 3 Windows 7 Pro machines

분류에서Dev

Racket and Geiser on Windows, strange path error

분류에서Dev

Sass installation issue in Windows 7

분류에서Dev

Prevent Windows System %PATH% from being prepended to user %PATH?

분류에서Dev

Workgroup connection issue (windows xp and 7)

분류에서Dev

Ubuntu 15.10 then windows 7 dual boot issue

분류에서Dev

Windows 7 Administrator Command Prompt "Start in" Path

분류에서Dev

Windows 7 does not update the default application path

분류에서Dev

Windows 7 - User-specific %PATH%

분류에서Dev

Where is TMOUT being set in CentOS 7? How can I disable it?

분류에서Dev

Strange Java serialization issue

분류에서Dev

Strange ssh connection issue

분류에서Dev

UAC being turned off once a day on Windows 7

분류에서Dev

Windows 10 shuts down after being in sleep mode overnight

분류에서Dev

Windows 10 and chrome, font issue after migrating from windows 8.1

분류에서Dev

Cookies not set with RestSharp in Windows Phone 7 app

분류에서Dev

Windows 7 fails to boot after hardware change

분류에서Dev

Windows 7 not booting after installing Ubuntu 14.04.03

분류에서Dev

7zip - Command Line: how to set output path?

분류에서Dev

CRLF issue when running Django via Vagrant on Windows 7

분류에서Dev

Incredibly strange JavaScript date issue

분류에서Dev

Strange issue with 64 bit OS

분류에서Dev

Add "django-admin.py" path to command line on Windows 7

분류에서Dev

Windows 7-사용자 별 % PATH %

분류에서Dev

Java home path error while configuring hadoop in windows 7

분류에서Dev

Strange Windows Errors

분류에서Dev

update-alternatives: "alternative path doesn't exist" issue while updating JDK7

분류에서Dev

Prevent packages from being removed after doing `dpkg --set-selections`

분류에서Dev

Rails strange behaviour on "not null" column

Related 관련 기사

  1. 1

    Strange copy and paste issue across 3 Windows 7 Pro machines

  2. 2

    Racket and Geiser on Windows, strange path error

  3. 3

    Sass installation issue in Windows 7

  4. 4

    Prevent Windows System %PATH% from being prepended to user %PATH?

  5. 5

    Workgroup connection issue (windows xp and 7)

  6. 6

    Ubuntu 15.10 then windows 7 dual boot issue

  7. 7

    Windows 7 Administrator Command Prompt "Start in" Path

  8. 8

    Windows 7 does not update the default application path

  9. 9

    Windows 7 - User-specific %PATH%

  10. 10

    Where is TMOUT being set in CentOS 7? How can I disable it?

  11. 11

    Strange Java serialization issue

  12. 12

    Strange ssh connection issue

  13. 13

    UAC being turned off once a day on Windows 7

  14. 14

    Windows 10 shuts down after being in sleep mode overnight

  15. 15

    Windows 10 and chrome, font issue after migrating from windows 8.1

  16. 16

    Cookies not set with RestSharp in Windows Phone 7 app

  17. 17

    Windows 7 fails to boot after hardware change

  18. 18

    Windows 7 not booting after installing Ubuntu 14.04.03

  19. 19

    7zip - Command Line: how to set output path?

  20. 20

    CRLF issue when running Django via Vagrant on Windows 7

  21. 21

    Incredibly strange JavaScript date issue

  22. 22

    Strange issue with 64 bit OS

  23. 23

    Add "django-admin.py" path to command line on Windows 7

  24. 24

    Windows 7-사용자 별 % PATH %

  25. 25

    Java home path error while configuring hadoop in windows 7

  26. 26

    Strange Windows Errors

  27. 27

    update-alternatives: "alternative path doesn't exist" issue while updating JDK7

  28. 28

    Prevent packages from being removed after doing `dpkg --set-selections`

  29. 29

    Rails strange behaviour on "not null" column

뜨겁다태그

보관