How to change environment variable to running process in windows?

2

I'm try to set new environment variables to too any new child-process in Windows platforms.

For example. I'm using sublime, and I run build command from sublime. (the build command may be a BAT file)

I want to change the PATH, and I want that all new build processes will use the new path. But sublime uses the old path, and the build process inherits this.

Aminadav Glickshtein

Posted 2016-11-02T07:21:43.700

Reputation: 396

Answers

0

It appears to be impossible to modify the environment of a running process unless you attach as a debugger or profiler. It's also a bad idea. Programs are usually designed to check environment variables once and not continually check if they were modified. Unless you manage to get the variable changed in the few ms before the process read the environment, your change would go unnoticed.

It'd be far better to get sublime is to properly accept the new PATH; or to have sublime run a script file (BAT, Powershell, whatever) that first sets the PATH and then executes the build process.

Ross Presser

Posted 2016-11-02T07:21:43.700

Reputation: 1 139