Camille said:
From what I have heard it is NOT necessary to reboot when I change an environment variable.
But much to my surprise WinXP did not recognize such a new env value otherwise!
Hi Camille
You can change environment variables at any time. However, this will
only change the environment block for new processes created *after* the
change. Existing processes will keep on using their current
environment block, which is the same as it was before you made the
change. New processes will inherit the changed environment.
A process can elect to update its environment block dynamically, by
calling SetEnvironmentVarible(). But an application needs to be written
to explicitly do this; there's no mechanism in the operating system to
universally update environment variables on the fly for running processes.
For example, say you had a command prompt open, and you run a SET
command to display the current variables. You will see what is in that
instance of CMD.EXE's environment block. Now, update the environment
variables via System Properties, Advanced, Environment Variables. Now
open a new instance of the Command Prompt and type SET. Run SET again in
the old Command Prompt. Compare the output of SET in the "before" and
"after" Command Prompts. You will see that SET in the new Command Prompt
will display the updated values for the variables; SET in the old
Command Prompt continues to display the variables from before the change.
If you are running squirrel.bat from a Command Prompt, you would need to
open a *new* Command Prompt after updating the environment variable, in
order for the variable change to be recognised.
There are some additional subtleties around System vs User variables
etc, but I think the above cuts to the heart of your problem.
The Windows shell application (usually Explorer.exe) listens for
WM_SETTINGSCHANGE messages, and will update its copy of the environment
dynamically.
Batch files aren't processes in their own right, they just run in the
context of whatever application was used to start them - usually
CMD.EXE. Otherwise, they inherit the environment from CSRSS.EXE.
See here for some official Microsoft doco, explaining in more detail:
http://msdn.microsoft.com/en-us/library/ms682653(VS.85).aspx
In summary, to make sure a changed environment is recognised, you need
to launch a new process after the change. Generally, you should never
*need* to reboot (although in some circumstances, that might be the
easiest way to get an update recognised)
Hope it helps,
Andrew