I have a service which invokes a batch file which runs a Powershell script which calls SETX to update an environment variable. The environment variable gets changed, but the change apparently isn't pushed into my service. Some time later, the service invokes a process which relies on this environment variable being updated. If it gets a stale environment variable, it causes my system to fail. SETX called from a command prompt running under a user session does push the fresh environment variables to my service, so I know that SETX works in this case, just not when it is being run from my service. Changing the environment variable is easy. Pushing that change to the service, that is hard apparently.
I need a way to get fresh environment variables to processes started by my service. Presumably this involves finding a way to push updates to environment variables from a service.