I ran into the same problem, and I hate to say it after all that work, but
all you have to do is use Win32::AdminMisc::SetEnvVar().  Check out
http://www.roth.net/perl/adminmisc for the syntax.

-----Original Message-----
From: Alexander, Mark P (XR&T) [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 23, 2001 9:32 AM
To: [EMAIL PROTECTED];
[EMAIL PROTECTED]
Subject: RE: Activate environment


If you can't find a way with just perl, try setx. It's a resource kit
utility that will export variables to the system environment.

-----Original Message-----
From: Alexander Apprich [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 23, 2001 3:32 AM
To: [EMAIL PROTECTED]
Subject: Activate environment


Hi all!

I wrote a script which extends the PATH environment in the registry
of Winnt and Win2k. The only problem I have is, how can I activate
the path without loggin out or rebooting the system?

[**script**]
use Win32::Registry;

my $Key;
my $KeyName = "SYSTEM\\CurrentControlSet\\Control\\Session
Manager\\Environment";
my $Value = "Path";
my $newpath = "c:\\programme\\jre\\1.3.1\\bin";

if ($HKEY_LOCAL_MACHINE->Open($KeyName, $Key)) {
  my ($DataType, $Data);
  if ($Key->QueryValueEx($Value, $DataType, $Data)) {
    if ((REG_SZ == $DataType) || (REG_EXPAND_SZ == $DataType)) {
      if (! ($Data =~ m/c:\\programme\\jre\\1.3.1\\bin/)) {
        print "Value not set, create it..\n";
        $Data = "$Data;$newpath";
        $Key->SetValueEx($Value, 0, $DataType, $Data);
      }else{
        print "Value allready exists!\n";
        print "$Data";
      }
    }
  }
  $Key->Close || warn "Can't close registry!\n";
}
[**script**]

Any help will be greatly appriciated.

Alex
-- 
  Alexander Apprich              Phone +49 (0)7071-9457-291
  science + computing ag         FAX   +49 (0)7071-9457-211
  Hagellocher Weg 73
  D-72070 Tuebingen              Email: [EMAIL PROTECTED]
You think that everybody is the same.
I don't think anybody is like you.
Just think about it... you'll get it... (Limp Bizkit: Re-arranged)
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin


--------------------------------------------------------------------------------
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.
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin

Reply via email to