The MASM Forum

General => The Workshop => Topic started by: jj2007 on May 11, 2021, 09:46:03 AM

Title: Where is the PATH environment variable in the registry?
Post by: jj2007 on May 11, 2021, 09:46:03 AM
When I type, in a DOS prompt, PATH, it shows me a long list of paths, including TDM-GCC-32. Since there is no longer such a folder on my machine, I got curious and searched the registry for TDM-GCC-32. No luck :sad:
Same for a second search as Admin. Where does the PATH hide?

It's not HKEY_CURRENT_USER\Environment\PATH
It's not HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PATH

They both contain lots of more or less useful paths, but not the TDM-GCC-32 that a DOS prompt echos as PATH :cool:
Title: Re: Where is the PATH environment variable in the registry?
Post by: hutch-- on May 11, 2021, 11:15:02 AM
Look for your system properties dialog. Should have a button near the bottom, Environment Variables.

If you have not done them for a while, separate items with -> ; <-
Title: Re: Where is the PATH environment variable in the registry?
Post by: jj2007 on May 11, 2021, 05:37:28 PM
If it was that simple, I wouldn't have asked, Hutch. Fact is that my console echos TDM... as part of PATH, but it does not show anywhere in the registry; I've done two full searches, as user and as admin.

Since Windows has abandoned the use of *.ini files a while ago, I wonder where this info could be stored.

(and no, the DOS prompt is not a child process of some parent who set the environment)
Title: Re: Where is the PATH environment variable in the registry?
Post by: hutch-- on May 11, 2021, 06:36:35 PM
On both my win7 of the past and 4 win10 machines, go to settings and find the system dialog, it is a CPL app.
Run this.

    exec "rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl"

exec is just a macro around CreateProcess().

Then "Advanced" then "Environment variables".

This is the only access I know of that lets you edit the path.
Title: Re: Where is the PATH environment variable in the registry?
Post by: jj2007 on May 11, 2021, 06:40:45 PM
You can also press Win R and paste rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl
Sure, that works, but it does not solve the mystery where my current PATH stores the TDM... string. It should sit in the registry somewhere, but it doesn't.

In the meantime, I rebooted my system and voilĂ , the TDM... stuff disappeared. So it seems what hangs around in memory is not necessarily a copy of what's in the registry. Windows at its best :cool:
Title: Re: Where is the PATH environment variable in the registry?
Post by: hutch-- on May 11, 2021, 07:16:49 PM
Microsoft probably hide it somewhere for security reasons. It sounds like you want to modify the permanent path string rather than use "set" which will usually only give you path changes for the duration of the command iterpreter.
Title: Re: Where is the PATH environment variable in the registry?
Post by: jj2007 on May 11, 2021, 07:44:03 PM
Quote from: hutch-- on May 11, 2021, 07:16:49 PM
Microsoft probably hide it somewhere for security reasons. It sounds like you want to modify the permanent path string rather than use "set" which will usually only give you path changes for the duration of the command iterpreter.

Actually, I was just curious why I couldn't find parts of the PATH in the registry. Setting environment variables temporarily is not trivial but still straightforward. My SetLaunchEnvironment macro sets the lpEnvironment argument of CreateProcessW used in Launch.

include \masm32\MasmBasic\MasmBasic.inc
  Init
  StringToArray Chr$("oJJA=Just a test", 10, "oJJB=it works!"), my$()
  SetLaunchEnvironment my$()
  FileWrite "~tmp.bat", cfm$("@echo off\necho A=%oJJA%\necho B=%oJJB%\npause")
  Launch "~tmp.bat"
EndOfCode