Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are these strange environment variables?

I use GetEnvironmentString() to get the program's environment variables.

Every program has such result in the first:

=::=::\

I don't know what does it mean?

Here is the code :

LPWCH lpEnvString=GetEnvironmentStringsW();
 LPWSTR lpszVariable=(LPWSTR)lpEnvString;
 while (*lpszVariable)
 {
     wprintf(L"%s\n",lpszVariable);
     lpszVariable+=wcslen(lpszVariable)+1;
 }
 FreeEnvironmentStringsW(lpEnvString);

Also if we start listing such variables we would see stuff like:

=::=::\
=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
...

On the other hand, getenv("=ExitCode") or getenv("=C:") returns NULL.

Can you provide a proper documentation of this "feature", for example getenv() ignores such strings and how such values should be treated?

like image 904
unixstudio Avatar asked May 03 '12 12:05

unixstudio


People also ask

What are some examples of environmental variables?

SCRATCH is an example of an environment variable. When used as part of a command they need to be preceded by a '$', hence '$SCRATCH'. They are called environment variables because they are used to modify the environment in which some programs run on the central system.

What are environment variables used for?

An environment variable is a dynamic "object" on a computer, containing an editable value, which may be used by one or more software programs in Windows. Environment variables help programs know what directory to install files in, where to store temporary files, and where to find user profile settings.

What are environmental variables explain some environmental variable?

An environment variable is a dynamic-named value that can affect the way running processes will behave on a computer. They are part of the environment in which a process runs.

What are Python environment variables?

Environment variables are variables you store outside of your program that can affect how it runs. For example, you can set environment variables that contain the key and secret for an API. Your program might then use those variables when it connects to the API.


1 Answers

They are leftovers from cmd.exe emulating ms-dos directory handling, they basically have little use, and are more archaic than anything. Essentially, it keeps track of a per drive current directory, and is kept as an environment variable to pass to other processes with ease.

like image 143
Ryan Avatar answered Oct 07 '22 17:10

Ryan