8

Possible Duplicate:
What are these strange environment variables?

I'm trying to use GetEnvironmentStrings Win32API function to get environment variables and I receive some very strange key=value pairs (example enclosed with []):

[=::=::\]
[=C:=C:\Users\username\value]
[=ExitCode=00000001]
[ALLUSERSPROFILE=C:\ProgramData]
[APPDATA=C:\Users\artik\AppData\Roaming]
[CommonProgramFiles=C:\Program Files (x86)\Common Files]
[CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files]
[CommonProgramW6432=C:\Program Files\Common Files]
...

Obviously it does not seems to be a proper value for environment string as described there http://msdn.microsoft.com/en-us/library/windows/desktop/ms683187%28v=vs.85%29.aspx

Questions:

  • What is the expected behavior?
  • If there are "special variables like =ExitCode Why, for example getenv() does not show them (getenv("=ExitCode") returns NULL)
  • Can anybody provide pointers to documentation/specifications of this stuff.
Community
  • 1
  • 1
Artyom
  • 31,019
  • 21
  • 127
  • 215
  • Are you sure you are not reading beyond the returned array size? – RedX May 28 '12 at 09:47
  • 1
    Thought I had seen this before; http://stackoverflow.com/questions/10431689/what-are-these-strange-environment-variables unfortunately no direct answer as to what %::% is – Alex K. May 28 '12 at 10:18
  • @RedX yes, I'm sure, in fact I had seen some notes about such a strange strings but had not found a reason for that or documentation... – Artyom May 28 '12 at 10:51
  • 4
    It's an [internal implementation detail](http://blogs.msdn.com/b/oldnewthing/archive/2010/05/06/10008132.aspx) of the command prompt. See the duplicate question for a bit more discussion. – Deanna May 28 '12 at 11:02
  • 2
    Before you vote for closing, see that the "exact duplicate" has no answer and it is not exact duplicate... – Artyom May 28 '12 at 11:45
  • This was very stupid to close the question: (a) it is not full duplicate (b) the duplicate has no answer!!! – Artyom May 30 '12 at 03:12

0 Answers0