JVD
JVD

Reputation: 655

Location of System PATH Environment variable in Windows Registry?

I am looking for a way of retrieving the "Windows System Environment Variables", as shown in the GUI dialog :

Control Panel -> System Properties -> Advanced Tab -> Environment Variables

from the command line, on Windows 10 for x86_64, Build 19042.746, Version 20H2 , fully up-to-date as of 2021/01/20.

Retrieving the persistent User environment variables is no problem, with a command like:

 C:\>REG QUERY HKCU\Environment /v Path HKEY_CURRENT_USER\Environment
 Path    REG_EXPAND_SZ    %USERPROFILE%\AppData\Local\Microsoft...

But there appears to be no registry entry containing the "System Variables". I have searched in RegEdit for any value containing a string in my System $Path, with no success.

Rumors have it on the web that the System Environment variables are meant to be stored on in the Registry at:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

But there is no such key in my Registry - from a System Administrator 'CMD.EXE' prompt, I try the following with no success:

C:\>REG QUERY 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session -\  
              Manager\Environment' /v 'Path'
ERROR: Invalid key name.
Type "REG QUERY /?" for usage.

C:\>REG QUERY 'HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\ -\   
              Environment' /v 'Path'
ERROR: Invalid key name.
Type "REG QUERY /?" for usage.

C:\>REG QUERY 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment' -\ 
              /v 'Path'
ERROR: Invalid key name.
Type "REG QUERY /?" for usage.

If anyone might know what key the system path is stored under, please post it here.

I have read all the Microsoft Registry and 'REG.EXE' reference documentation with no light being shed on this matter at all.

All the names on the web for the system environment variable key name seem to be out of date.

Would anyone know what it is ?

Or perhaps how to convert the Registry into an ASCII or UTF-8 text file so that I could search for strings in it? ( 'REGEDIT -e output_file' does not work - it produces a 96MB
binary file 'output_file' in some format that does not allow text searching. ).

Thanks in advance for any replies!

Upvotes: 1

Views: 6382

Answers (1)

Andre Kiki
Andre Kiki

Reputation: 11

Simple , use " and not ' for quoting space.

REG QUERY "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /s

That is to have all environment vars with a particular path.

Upvotes: 1

Related Questions