regedit.exe, navigate to
HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment. Create two environment variables:
Name Type Data ----- -------------- ----------- zbar REG_SZ water zfoo REG_EXPAND_SZ %zbar%
powershell.exe or whatever. These variables are missing. Make LogOff, then LogOn. In
cmd.exe window type
echo %zbar% -
water is displayed. Type
echo %zfoo% and
%zbar% is displayed, but I expect to see expanded value -
And now. Open Windows Environment Variables dialog. Alter or create any variable (for example
cmd.exe and type
echo %zfoo% - now you see
Actually, I am creating these variables with PowerShell script. But all this script does is described registry manipulations.
- How to force
zfoovariable to have a correct value without that magic with opening Windows Environment Variables dialog and altering some variables? Maybe I should call some API, something like
- It is possible to make these variables visible to users without need for LogOff/LogOn operations? If I edit user-level environment variables (also in registry) they are immediately available, but with global - they are not.