OK, I've started the script with perl -d and I receive a Signal SEGV: error on the SetEnvVar command. I am using Perl 5.6.1 635 on a W2K Adv. Server with SP4 thru a Terminal Server session.
All suggestions are welcome now. Thx, Bob -----Original Message----- From: Tim Johnson [mailto:[EMAIL PROTECTED] Sent: vrijdag 14 november 2003 10:26 To: Bob Gervais; [EMAIL PROTECTED] Subject: RE: How to change the uservariables in Windows 2000 As far as I can see that should work, unless there is somthing strange about doing it in a TS session. One thing I'm noticing, though, is that you are not checking to see if it worked, ala "Win32::AdminMisc::SetEnvVar("VCSID",$VCSID) || die;". Also, you may want to rethink that last part. A simple regex will make your code much easier to follow: #if it matches "user" followed by a number(\d) at the end($), case insensitive(i) if($UserLoginName =~ /user(\d)$/i){ #append to the end of the path $ENV{PATH} .= ";D:\\User$1"; }else{ #or return an error print "Invalid Username"; } -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Bob Gervais Sent: Friday, November 14, 2003 12:57 AM To: [EMAIL PROTECTED] Subject: How to change the uservariables in Windows 2000 Hi, I am trying to change the path in Windows 2000 (terminal server session) on a per user basis and set a specific variable. I have tried to use Win32::AdminMisc, but this only changes the path and the variable during the time the script runs. Is there a way to set the path globally (at logon) so the user can use during his/her session? Please keep in mind that I am no "real" programmer, just a sysadmin trying to automate some tasks with perl. Here is the script I wrote: ------------------------------------------------------------------------ --- #!perl use win32::adminmisc; use win32; use strict; my $UserLoginName = $ENV{"USERNAME"}; my $Fixed_Path = $ENV{"PATH"}; my $VCSID = uc(substr($UserLoginName,0,3)); Win32::AdminMisc::SetEnvVar("VCSID",$VCSID); my $UserPath; for ($UserLoginName) { if ($UserLoginName eq "domainuser1") { $UserPath = $Fixed_Path.";d:\\User1" } elsif ($UserLoginName eq "domainuser2") { $UserPath = $Fixed_Path.";d:\\User2" } elsif ($UserLoginName eq "domainuser3") { $UserPath = $Fixed_Path.";d:\\User3" } elsif ($UserLoginName eq "domainuser4") { $UserPath = $Fixed_Path.";d:\\User4" } elsif ($UserLoginName eq "domainuser5") { $UserPath = $Fixed_Path.";d:\\User5" } elsif ($UserLoginName eq "domainuser6") { $UserPath = $Fixed_Path.";d:\\User6" } }; Win32::AdminMisc::SetEnvVar("PATH",$UserPath); ------------------------------------------------------------------------ --- Thanx, Bob _______________________________________________ Perl-Win32-Admin mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs _______________________________________________ Perl-Win32-Admin mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
