0

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.

4
  • Did you try restarting the service?
    – DavidPostill
    Commented Aug 18, 2015 at 8:00
  • This is a persistent issue across reboots. Of course the service gets fresh environment variables on a restart, but I need it to get fresh variables while running. In particular, I am setting DEVPATH.
    – Void Star
    Commented Aug 18, 2015 at 15:51
  • What user is your service running as?
    – DavidPostill
    Commented Aug 18, 2015 at 16:52
  • I am running under a domain user account. It is not the same account that I use to log in as to develop and manage my system typically, but to avoid confusion lately I have been logging in with the same account as I run the service under. It doesn't seem to make a difference though.
    – Void Star
    Commented Aug 18, 2015 at 17:03

0

You must log in to answer this question.

Browse other questions tagged .