NAME
Win32::Env - get and set global system and user enviroment varialbes under Win32.
VERSION
Version 0.01
SYNOPSIS
use Win32::Env;
my $user_path=GetEnv(ENV_USER, 'PATH');
# Limit PATH for other programs to system path and specified directory for 10 seconds
SetEnv(ENV_USER, 'PATH', 'C:\\Perl\\bin');
BroadcastEnv();
sleep(10);
# Restore everything back
SetEnv(ENV_USER, 'PATH', $user_path);
BroadcastEnv();
EXPORT
SetEnv GetEnv BroadcastEnv ENV_USER ENV_SYSTEM
FUNCTIONS
SetEnv($sys_or_usr, $variable, $value)
Sets variable in enviroment to specified value. $sys_or_usr
specifies either current user's enviroment with exported constant ENV_USER
or system's global environment with ENV_SYSTEM
.
GetEnv($sys_or_usr, $variable)
Returns value of enviroment variable. Its difference from plain $ENV{$variable}
is that you can (and must) select current user's or system's global enviroment with $sys_or_usr
. It is selected with same constants as in #SetEnv.
BroadcastEnv()
Broadcasts system message that enviroment has changed. This will make system processes responsible for enviroment aware of change, otherwise your changes will be noticed only on next reboot. Note that most user programs still won't see changes until next run and that your changes will not be available in %ENV
to either your process or any processes you spawn. Assign to %ENV
yourself in addition to SetEnv
if need it.
AUTHOR
Oleg "Rowaa[SR13]" V. Volkov, <ROWAA at cpan.org>
BUGS / TODO
Only first argument to GetEnv
/SetEnv
is checked right now. Considering that functions work with Windows registry, more sanity checks should be added to other arguments.
Any limitations of Win32::TieRegistry apply to this module too, because it is used to write all changes to the registry.
Please report any bugs or feature requests to bug-win32-env at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Win32-Env. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Win32::Env
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
RT: CPAN's request tracker
Search CPAN
COPYRIGHT & LICENSE
Copyright 2006 Oleg "Rowaa[SR13]" V. Volkov, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.