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

Reply via email to