View Full Version : refreshing environment variables while processing batch file


Pedro CR
09-05-2005, 05:19 AM
hi

i am trying to write a bath file that first calls a wsh script that sets an
environment variable and later in the same batch file that variable is
needed as an argument to a program that is called.
the problem is that, although the script sets the envirnment variable
correctly, it is not available to the console who called the script. I
assume that the problem is that the console does not refresh its environment
variables, because if I open a new console, the environment variable is
there.

What I wanted to know was if there a way to force the console to reload the
environment variables while processing the batch file, and making the new
environment variable visible to the console who ran it and batch file being
processed in that console.

thanks in advance
pedro

Jerold Schulman
09-05-2005, 12:26 PM
On Mon, 5 Sep 2005 05:19:21 +0100, "Pedro CR" <pramilo@n0.spam.sapo.pt> wrote:

>hi
>
>i am trying to write a bath file that first calls a wsh script that sets an
>environment variable and later in the same batch file that variable is
>needed as an argument to a program that is called.
>the problem is that, although the script sets the envirnment variable
>correctly, it is not available to the console who called the script. I
>assume that the problem is that the console does not refresh its environment
>variables, because if I open a new console, the environment variable is
>there.
>
>What I wanted to know was if there a way to force the console to reload the
>environment variables while processing the batch file, and making the new
>environment variable visible to the console who ran it and batch file being
>processed in that console.
>
>thanks in advance
>pedro
>

Try using SETENV.EXE to set the environment variable.
See tip 4928 » SETENV.EXE is a freeware replacement for SETX.EXE, and it has more functionality.
in the 'Tips & Tricks' at http://www.jsifaq.com

Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
http://www.jsifaq.com