[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3-unattended/var/se3/unattended/install/bin/ -> fixtz.pl (source)

   1  # Script to set timezone to its current value.
   2  
   3  # See documentation at bottom for details.
   4  
   5  use warnings;
   6  use strict;
   7  use Getopt::Long;
   8  use Pod::Usage;
   9  use Win32::OLE;
  10  
  11  # Your usual option-processing sludge.
  12  my %opts;
  13  GetOptions (\%opts, 'help|h|?')
  14      or pod2usage (2);
  15  
  16  (exists $opts{'help'})
  17      and pod2usage ('-exitstatus' => 0, '-verbose' => 2);
  18  
  19  # Ensure no arguments after options.
  20  scalar @ARGV == 0
  21      or pod2usage (2);
  22  
  23  # Bomb out completely if COM engine encounters any trouble.
  24  Win32::OLE->Option ('Warn' => 3);
  25  
  26  # Get a handle to the SWbemServices object of the machine.
  27  my $computer = Win32::OLE->GetObject ('WinMgmts:');
  28  
  29  # Get the set of time zone objects (should be only one).  See:
  30  # <http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_timezone.asp>
  31  my $tz_set = $computer->InstancesOf ("Win32_TimeZone");
  32  
  33  # Convert set to Perl array.
  34  my @tzs = Win32::OLE::Enum->All ($tz_set);
  35  
  36  # Grab first (only) element, which is our current time zone.
  37  scalar @tzs == 1
  38      or die "Internal error";
  39  my $tz = $tzs[0]->{'StandardName'};
  40  
  41  print "Resetting timezone [$tz]...\n";
  42  
  43  my $ret = system "control.exe timedate.cpl,,/Z $tz";
  44  
  45  # Status 1 is normal, apparently.
  46  $ret == 0 || $ret == 256
  47      or die "timedate.cpl failed, status ", int($ret / 256), '.', $ret % 256;
  48  
  49  print "...done.\n";
  50  
  51  exit 0;
  52  
  53  __END__
  54  
  55  =head1 NAME
  56  
  57  fixtz.pl - Work around daylight saving bug in XP unattended install
  58  
  59  =head1 SYNOPSIS
  60  
  61  fixtz.pl [ options ]
  62  
  63  Options:
  64  
  65   --help                 Display help and exit
  66  
  67  =head1 NOTES
  68  
  69  Windows XP unattended installation has a bug where daylight saving
  70  time does not take effect.  If you use the TIMEDATE.CPL control panel
  71  simply to set the time zone to its *current* value (which should be a
  72  no-op), daylight saving time is then computed correctly.  This script
  73  automates this process.
  74  
  75  =head1 SEE ALSO
  76  
  77  C<http://groups.google.com/groups?selm=3E657793.CB1A5467%40hydro.com>


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1