develooper Front page | perl.beginners | Postings from January 2002

RE: How to export environment variables in Win32

Thread Previous | Thread Next
Timothy Johnson
January 31, 2002 11:02
RE: How to export environment variables in Win32
Message ID:

Download the Win32::AdminMisc module from  The
SetEnvVar() function will do what you want.  Keep in mind that while new
windows will have the new environment variables, the environment the script
is running uner will still have to be set manually using the %ENV hash or
the set command.

-----Original Message-----
From: Pozsar Balazs []
Sent: Thursday, January 31, 2002 10:45 AM
To: Adriano Rodrigues Ferreira
Subject: Re: How to export environment variables in Win32

It is neither possible in unix.
When you run a batch script under Win32, or 'source' a shell script under
unix, you only have 1 process, and that process is executing commands,
which set _its_ env variables.

If your fork a child process (ie. start perl to execute the perl-script),
it can only change its own env, it cannot change the env of any other
processes (including its parent).

On Thu, 31 Jan 2002, Adriano Rodrigues Ferreira wrote:

> I thought it would be a good idea to replace a batch script
> (.bat) running on a Windows 2000 with a Perl script which
> is far more clever.
> The original batch file setted two environment variables
> which were available after running the script. That is,
> if I did
> c:> cvs-init.bat
> it has commands like
>      set CVSROOT=:pserver:user@aCVSserver:/usr/local/cvsroot
> and then I could verify
> c:> set CVSROOT
> CVSROOT=:pserver:user@aCVSserver:/usr/local/cvsroot
> To set environment variables in Perl, I first tried 'system' calls.
> They worked but the environment variables were reset to the
> previous values after the script ended.
> I tried the Env module. The same result.
> What it is missing is something to export the environment
> variables to the outer shell executing the Perl interpreter.
> Just like what is done in Unix by a command like
> $ . ./
> Is it possible in Win32?
> Best regards,
> Adriano.
> --
> To unsubscribe, e-mail:
> For additional commands, e-mail:


To unsubscribe, e-mail:
For additional commands, e-mail:

This email may contain confidential and privileged 
material for the sole use of the intended recipient. 
If you are not the intended recipient, please contact 
the sender and delete all copies.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About