Where are my environment variables set on Vista32?

2019-08-24 06:43发布

By following:

Start -> Computer -> Right Click -> Properties -> Advanced System Settings -> Advanced -> Environment Variables

I find User variables for brianjd (which includes TMP and TEMP) and System Variables (which includes, Path, USERNAME, etc.). I would expect these variables to be set in C:\AUTOEXEC.BAT or C:\CONFIG.SYS. Instead, I find REM Dummy file for NTVDM and FILES=40 in those files.

Q: Where are the files that actually set the environment variables with statements like SET USERNAME=brianjd?

Q: When I follow the Windows GUI path above and add the variable name and value FOO and C:\foo to either User variables for brianjd or System Variables, what is actually happening? What is Windows writing to where?

1条回答
forever°为你锁心
2楼-- · 2019-08-24 07:29

The variables are not in a script file like /etc/environment on Linux, for example. Windows stores them in the registry. The keys are "HKCU\Environment" (user variables) and "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" (system-wide variables).

See also the relevant MSDN article.

查看更多
登录 后发表回答