Setting Environment variables in Windows NT
Information in this article applies to NT 3.5, 3.51, 4.0 and probably beyond.
User environment variables editing the following Registry key using the RegSetExpSz function
HKEY_CURRENT_USER \ EnvironmentSystem environment variables editing the following Registry key using the RegSetExpSz function
HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Control \ Session Manager \ EnvironmentNote, however, that modifications to the environment variables do not result in immediate change. For example, if you start another Command Prompt after making the changes, the environment variables will reflect the previous (not the current) values. The changes do not take effect until you log off and then log back on.
To effect these changes without having to log off, broadcast a WM_WININICHANGE message to all windows in the system, so that any interested applications (such as Program Manager, Task Manager, Control Panel, and so forth) can perform an update. The WININICHG is for telling running applications it changed. Newly run applications will pick up the environment automatically. This is done as follows:
Current versions
IntControl(59, -1, "Environment", 0, 0)Older Versions
WININICHG=26 DaDll=Strcat(DirWindows(1),"USER32.DLL") DllCall( DaDll, long:"SendMessageA", long:-1, long:WININICHG, long:0, lpstr:"Environment")
Article ID: W12921Filename: NT Environment variables.txt