Microsoft has a knowledge base article, last reviewed in June 2007, which states:

If you update environment variables or add new environment variables, you must restart the computer before the changes that you make affect services that run under the Local System account.

It's unclear to me whether this holds true for Windows Server 2008 R2. Can anyone advise?

I notice there is a hotfix for Windows 2003 that solves this problem. Consequently I wonder if 2008 R2 has rolled in this fix. I can't find any evidence to suggest there is still a problem with Windows 2008 R2, but a lack of evidence is less comforting than a concrete statement to the contrary.

A related question covers similar ground, but doesn't discuss Windows 2008.


Restarting a service will pickup changes to system environment variables.

To check: Use SysInternals Process Explorer to inspect the environment of a service process before and after changing/adding a System environment variable and restarting the service. Note: Use "Run as administrator" on procexp.exe to see all properties of system processes.

enter image description here

enter image description here

  • This. If a new process is spawned under the local 'System' account, said new process gets a new environment (w/ any modifications made). Hence, restarting a service will re-read the environment. – Signal15 Nov 19 '14 at 21:13
  • I can confirm by direct experiment that restarting a service causes a re-read of system environment variables, on Windows 7. This works for IIS and its w3wp worker processes. It also works for non-LocalSystem services, such as STISVC. – William Jan 19 '16 at 0:00

Sure. Any process sees the environment variables AS THEY ARE WHEN THE PROCESS STARTS. It basically gets a copy.

So, if you need them to be picked up by services - restart the services. If you need them to be picked up by windows, restart windows.

Especially because the local system account is keeping this copy around ;) So - no. This still holds true. I would generally say that changing this is a "near zero priority" item as this kind of change is quite rare.

  • I found the last paragraph a little confusing - in summary, you think this still applies to Windows 2008 and a reboot is required? If so, do you have any evidence to support that claim? I notice that a hotfix was available for Windows 2003 that resolves the issue - are you sure this isn't incorporated into 2008 R2? – Duncan Jones Nov 11 '14 at 10:42

Possible via nasty hack while running. Otherwise only by restart.

Just verified that environment variables can be changed with Cygwin GDB. Tried with x86 Cygwin and x86 Winword. Verified with ProcExp.exe.

GDB commands found here: https://stackoverflow.com/questions/205064/is-there-a-way-to-change-another-processs-environment-variables

Microsoft says this isn't the regular way of doing this: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682009(v=vs.85).aspx

Altering the environment variables of a child process during process creation is the only way one process can directly change the environment variables of another process. A process can never directly change the environment variables of another process that is not a child of that process.

My earlier edit:

My best guess: Service needs to be restarted. At least.

A process will upon creation inherit the enviroment variables from its parent. (http://msdn.microsoft.com/en-us/library/windows/desktop/ms682653(v=vs.85).aspx)

So: The process must be restarted AND there must be something for it to inherit.

How to check
Check for yourself using ProcExp.exe. (http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx ) Double-click the process you're interested in and then select the "Environment" tab.

To find the parent double-click the child, select the "Image" tab and read the "Parent:" row.

Repeat all the way up the heritage line.

  • I understand how environment variable inheritance normally works. I'm asking about a specific situation here, one that was identified as an issue by Microsoft and later addressed in a hotfix for Win 2003. I've raised the bounty because I'm looking for a concrete, authoritative reference that addresses my specific question. I'm fully expecting a service restart is required, what's important is whether a reboot of the machine is needed. – Duncan Jones Nov 14 '14 at 9:33
  • So the question is: "Has the Win2003 KB887693 hotfix been integrated into out-of-the-box Windows Server 2008 or not?" Right? I can't give an authoritative source for that. (Maybe another helpful tidbit: This KB951859 mentions your KB887693 entry.) – StackzOfZtuff Nov 14 '14 at 10:16
  • Well, the question is simply "Do I need to reboot a Win2008 server so that a Local System service can pick up changes to environment variables". So far, the answers seem to have been based on the standard theories of processes and inheritance of env variables. I'm waiting for something a little more concrete, specifically in light of the presence of a Win2k3 hotfix. I will try to use your ProcExp ideas to probe this further myself with experiments. – Duncan Jones Nov 14 '14 at 10:19

@Brian answer does not cover all use cases. In my case, I've upgraded Java on Windows 7 x64 machine from version 7 to 8. After that, the service which depends on Java failed to start ("net start SymmetricDS") because the system could not find Java executable.

I.e. services.exe (parent process of all LocalSystem services) does not pick up environment variables' changes itself. It just does so for new spawned child processes. I've confirmed it by looking at it with SysInternals Process Explorer. Proof: http://workblog.pilin.name/2013/03/service-environment-variables.html. It doesn't say which versions of Windows does it apply to, but the date of publication is rather new, so I think it applies to Windows 7 and Windows Server 2008.

Solved the problem by making symlinks to Java executables in one of folders in old PATH contained in services.exe.

  • i.e. in my case, services.exe could not start new service because it was located in a directory that was not in old PATH value cached by services.exe. – Alexandr Zarubkin Jul 7 '16 at 18:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.