For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > April 2005 > RE: Edit Windows PATH









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author RE: Edit Windows PATH
Luke Bakken

2005-04-27, 3:56 pm

Chris Devers wrote:
> On Fri, 1 Jan 1988, amr wrote:
>=20
>=20
> Is there a reason that a simple system() command won't work here?
>=20
> my $status =3D system( "SET PATH=3D%PATH%;$new_path" );
> die "Couldn't set %PATH%: $!" if $status;
>=20
> Normally I'm opposed to using system commands when the task can be
> done either all in Perl or with a platform- and problem- specific
> module, but in this case, the cmd shell's SET command is easy to run
> directly, so why not just solve the problem that way?


That will change the environment for the cmd.exe process that is
executed by that one system() call. Changing %ENV will change the
environment for all processes started by the perl script.

Changing the global path requires registry trickery, IIRC.
Chris Devers

2005-04-27, 3:56 pm

On Wed, 27 Apr 2005, Bakken, Luke wrote:

> That will change the environment for the cmd.exe process that is
> executed by that one system() call. Changing %ENV will change the
> environment for all processes started by the perl script.


That's the behavior on POSIXy systems, but I had the impression that on
Windows the SET command would have a global effect.

I seem to remember using a variant of this to do things like set file
associations from the DOS shell on NT4, and being surprised that a
command I expected to only work for the current session having effects
on all future sessions. Maybe that was something else though...

But I avoid Windows as much as I can get away with, so I could easily be
wrong about this.



--
Chris Devers
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com