There are 2 things you can do.

1.  Edit "CurrentControlSet001" this is your "working copy" if you will and
will automatically update "CurrentControlSet".

2. Have the user run a "net time \\\someserver /set /y".  This seems to sync
everything up after I run a script and ensures that a. the script ran and b.
it worked and c. the user has the correct time.  This puts into effect the
changes you just made without a reboot In order to run this the user must
have the right to change the time.  You could however experiment with
running a generic net time.  This may work.  

See my scripts below. Use freely----->at your own risk.

---CHANGES ZONE TO GMT (NO DAYLIGHT) AFTER A SERIES OF CHECKS

#################Time Zone Set##################
################################################
use Win32::TieRegistry;
open (timelog, ">timelog.txt");
printf timelog ("%-20s %-25s %-25s\n\n\n","Computer Name","Time Zone
Before","Timezone After");
close timelog;
#####################OPENS LIST OF MACHINES TO OPERATE ON
open (FILE, "$ARGV[0]");

while (<FILE>)

        {
####CHECKS TO MAKE SURE MACHINE IS PINGABLE AND QUITS IF IT IS NOT (see sub
at bottom)
        print "\n";
        chomp;
        print "Trying $_\n";
        if (pingable($_))
                {
                print "$_ is pingable!!!\n";
                
###CONNECTS TO REMOTE MACHINE'S REGISTRY and sets working key
                $rmtreg =
$Registry->Connect($_,"LMachine",{Delimiter=>"#"});
                $rmtkey =
$rmtreg->{"System#CurrentControlSet001#Control#TimeZoneInformation"};

####LETS YOU KNOW OF SUCCESS AND LOGS MACHINES THAT SCRIPT COULDN'T CONNECT
WITH
                                if (not $rmtreg)
                                        {
                                        open (NOREG, ">>cantgetreg.txt");
                                        print NOREG "$_\T$!\n";
                                        close (NOREG);
                                        die "Failure of remote registry
fetch on $_!!!\t$!\n";
                                        }
                print "Succesful remote registry fetch on $_!!!\n";
                
                        
####Checks if change is required, makes chage if need be, logs actions to
testlog.txt                     
                        open (timelog, ">>timelog.txt");
                        printf timelog ("%-20s %-25s
",$_,$rmtkey->{DaylightName}); 
                        #print $rmtkey->{StandardName};
                        $keytest = $rmtkey->{StandardName};
                        if ($keytest eq "GMT Standard Time")
                                {
                                $rmtkey->{ActiveTimeBias} =
[pack("L",0),REG_DWORD] or die ("Couldn't do ActiveTimeBias");
                                $rmtkey->{DaylightBias} =
[pack("L",0),REG_DWORD] or die ("Couldn't do DaylightTimeBias");
                                $rmtkey->{DisableAutoDaylightTimeSet} =
[pack("L",1),REG_DWORD] or die ("Couldn't do DisableAutoDaylightTimeSet");
                                $rmtkey->{DaylightStart} =
[$rmtkey->{StandardStart},REG_BINARY] or die ("Couldn't do DaylightStart");
                                $rmtkey->{DaylightName} = "GMT Standard
Time" or die ("Couldn't do DaylightName");
                                }
                        printf timelog ("%-25s\n",$rmtkey->{DaylightName});
                        
}
if (not pingable($_))
                {               
                print "$_ is not pingable!!!\t$!\n";
                open (NOPING, ">>notpingable.txt");
                print NOPING "$_\t\t$!\n";
                close (NOPING);
}
}               
                
        
                
                ####    pingable returns 0 if host doesn't ping, 1 if it
does.
                
                sub pingable
                        {
                        use Net::Ping;
                        my $node = $_[0];
                        my $p = Net::Ping->new("icmp");
                        if ($p->ping($node))
                                {
                                $p->close();
                                return 1;
                                }
                        else
                                {
                                $p->close();
                                return 0;
                                }
                        } 


ADDS CHANGE TIME RIGHTS FOR EVERYONE----

###################GRANTS CHANGE SYSTEM TIME TO THE EVERYONE GROUP ON
machines in TEXT FILE
use Win32::Lanman;
open (FILE, "$ARGV[0]");
open (ERRORLOG, ">>ERRORLOG.txt");
while (<FILE>) {
 
 chomp;
 if(!Win32::Lanman::GrantPrivilegeToAccount("\\\\$_",
"SeSystemtimePrivilege",["everyone"]))
                {
                     print "Sorry, something went wrong on $_, logging
error: ";
                     # get the error code
                     print Win32::Lanman::GetLastError(), " to
ERRORLOG.TXT\n";
                     print ERRORLOG "$_\n";
                                 next;
                }
          
          print "Group:  \"Everyone\" given \"Set System Time\" right on
$_\n";
         
         }
         close ERRORLOG;

Hope this helps,

Tim McGuire
AT&T Solutions
Durham, NC
[EMAIL PROTECTED]


----original message------


Reply-To: <[EMAIL PROTECTED]>
From: "navilliat" <[EMAIL PROTECTED]>
To: "EDWARDS, John" <[EMAIL PROTECTED]>,
<[EMAIL PROTECTED]>
Subject: RE: changing time zones
Date: Tue, 31 Oct 2000 11:50:28 -0500
charset="iso-8859-1"

I have been doing this.  The problem seems to be that the PC does not
realize the change until it reboots, which is a drag.  I need to be able to
w/o rebooting the PCs, if at all possible.

Dan
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin

Reply via email to