1

I have a package which adds and removes an entry (say C:\my_entry) to PATH environment variable during installation and uninstallation respectively. I am able to see that entry is being added/removed to/from PATH variable by verifying the registry key

HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path

But I observed different values for PATH environment variable from command prompt.

After installation

If I open command prompt as ⊞ Win+R, Type cmd and then Enter, I am able to see C:\my_entry in PATH variable.

If I open command prompt(cmd.exe) from C:\Windows\System32 directory, I am unable to C:\my_entry in PATH variable.

After un-installation

If I open command prompt as ⊞ Win+R, type cmd and then Enter, I am still able to see C:\my_entry in PATH variable though it got removed from registry.

Please let me know why PATH environment variable value is different if we open command prompt from different locations? And why the PATH environment variable value is different in command prompt from the value present in Registry?

1 Answer 1

0

Environment variables are usually inherited – a new process gets a copy from whatever launched it, not from the registry. (ProcExp or Process Hacker can show the env of each individual process, along with the actual hierarchy.)

The only times the registry keys are read are when you log in, and when some program (such as an installer) tells all apps to refresh their env. (Usually only Explorer reacts to that request.)

So it could be that one Explorer process (the one handling the taskbar shell) refreshed its environment after installation, but the one handling folder windows didn't. (Or maybe you ran cmd from a third-party file manager.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .