Re: Setting file server time

2011-09-29 Thread Xiao Yafeng
Use WMI to query and set time and date on remote systems. You may need to
adjust privileges for your account to set time/date on the remote machine.

use Win32::OLE qw(in);

my $datetime = Win32::OLE-new(WbemScripting.SWbemDateTime) or die;
my $machine = shift @ARGV or .;
$machine =~ s/^[\\\/]+//;
my $wmiservices =
Win32::OLE-GetObject(winmgmts:{impersonationLevel=impersonate,(security)}//$machine)
or die;
foreach my $os ( in( $wmiservices-InstancesOf(Win32_OperatingSystem)))
{
  print Last Boot Time:.$os-{LastBootUpTime}.\n;
  print Current time:.$os-{LocalDateTime}.\n;
  $datetime-{Value} = $os-{LocalDateTime};
  printf( Current Time: %02d-%02d-%04d at %02d:%02d:%02d\n,
$datetime-{Month}, $datetime-{Day}, $datetime-{Year}, $datetime-{Hours},
$datetime-{Minutes}, $datetime-{Seconds} );
  print Setting time + 2 hours:;
  $datetime-{Hours} += 2;
  printf( Current Time: %02d-%02d-%04d at %02d:%02d:%02d\n,
$datetime-{Month}, $datetime-{Day}, $datetime-{Year}, $datetime-{Hours},
$datetime-{Minutes}, $datetime-{Seconds} );
  print \tHard value: $datetime-{Value}\n;
  $Result = $os-SetDateTime($datetime-{Value});
  print Result: $Result\n;
}

On Wed, Sep 28, 2011 at 4:04 AM, william.hoo...@l-3com.com wrote:

 I've used Win32-OLE to start/execute processes on remote computers.  In
 this scenario you could use Win32-OLE to call time



 -Original Message-
 From: perl-win32-users-boun...@listserv.activestate.com
 [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
 Barry Brevik
 Sent: Monday, September 26, 2011 8:24 PM
 To: Tobias Hoellrich; Howard Tanner;
 perl-win32-users@listserv.ActiveState.com
 Subject: RE: Setting file server time

 Yes NTP. Well, if the guy had it setup right it would work, but no. So I
 had to create an internet time server bot (with a little help) which
 sets the local machine time. I was hoping to employ a Win32-only
 solution to then set the domain controller rather than spawn one of the
 pstools (I am familiar with them).


  -Original Message-
  From: perl-win32-users-boun...@listserv.activestate.com
  [mailto:perl-win32-users-boun...@listserv.activestate.com] On
  Behalf Of Tobias Hoellrich
  Sent: Monday, September 26, 2011 4:44 PM
  To: Howard Tanner; perl-win32-users@listserv.ActiveState.com
  Subject: RE: Setting file server time
 
  Since the advent of NTP on the Windows platforms I don't
  remember the last time there was a need to set the time manually :-)
 
  Thanks- T
 
  -Original Message-
  From: Howard Tanner [mailto:tan...@optonline.net]
  Sent: Monday, September 26, 2011 5:26 PM
  To: Tobias Hoellrich; 'Barry Brevik';
  perl-win32-users@listserv.ActiveState.com
  Subject: RE: Setting file server time
 
  NET TIME was my first thought too, but it only allows you to
  set your time to that of another machine.
 
  ___
  Perl-Win32-Users mailing list
  Perl-Win32-Users@listserv.ActiveState.com
  To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
 
 ___
 Perl-Win32-Users mailing list
 Perl-Win32-Users@listserv.ActiveState.com
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 ___
 Perl-Win32-Users mailing list
 Perl-Win32-Users@listserv.ActiveState.com
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Setting file server time

2011-09-29 Thread Barry Brevik
Thank you very much for that post! I can not wait to try it.




From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Xiao Yafeng
Sent: Thursday, September 29, 2011 5:26 AM
To: william.hoo...@l-3com.com
Cc: perl-win32-users@listserv.activestate.com
Subject: Re: Setting file server time


Use WMI to query and set time and date on remote systems. You
may need to adjust privileges for your account to set time/date on the
remote machine.



use Win32::OLE qw(in);

my $datetime = Win32::OLE-new(WbemScripting.SWbemDateTime) or
die;
my $machine = shift @ARGV or .;
$machine =~ s/^[\\\/]+//;
my $wmiservices =
Win32::OLE-GetObject(winmgmts:{impersonationLevel=impersonate,(securit
y)}//$machine) or die;
foreach my $os ( in(
$wmiservices-InstancesOf(Win32_OperatingSystem)))
{
  print Last Boot Time:.$os-{LastBootUpTime}.\n;
  print Current time:.$os-{LocalDateTime}.\n;
  $datetime-{Value} = $os-{LocalDateTime};
  printf( Current Time: %02d-%02d-%04d at %02d:%02d:%02d\n,
$datetime-{Month}, $datetime-{Day}, $datetime-{Year},
$datetime-{Hours}, $datetime-{Minutes}, $datetime-{Seconds} );
  print Setting time + 2 hours:;
  $datetime-{Hours} += 2;
  printf( Current Time: %02d-%02d-%04d at %02d:%02d:%02d\n,
$datetime-{Month}, $datetime-{Day}, $datetime-{Year},
$datetime-{Hours}, $datetime-{Minutes}, $datetime-{Seconds} );
  print \tHard value: $datetime-{Value}\n;
  $Result = $os-SetDateTime($datetime-{Value});
  print Result: $Result\n;
}


On Wed, Sep 28, 2011 at 4:04 AM, william.hoo...@l-3com.com
wrote:


I've used Win32-OLE to start/execute processes on remote
computers.  In
this scenario you could use Win32-OLE to call time




-Original Message-
From: perl-win32-users-boun...@listserv.activestate.com

[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of

Barry Brevik
Sent: Monday, September 26, 2011 8:24 PM
To: Tobias Hoellrich; Howard Tanner;

perl-win32-users@listserv.ActiveState.com
Subject: RE: Setting file server time

Yes NTP. Well, if the guy had it setup right it would
work, but no. So I
had to create an internet time server bot (with a little
help) which
sets the local machine time. I was hoping to employ a
Win32-only
solution to then set the domain controller rather than
spawn one of the
pstools (I am familiar with them).


 -Original Message-
 From:
perl-win32-users-boun...@listserv.activestate.com

[mailto:perl-win32-users-boun...@listserv.activestate.com] On
 Behalf Of Tobias Hoellrich
 Sent: Monday, September 26, 2011 4:44 PM
 To: Howard Tanner;
perl-win32-users@listserv.ActiveState.com
 Subject: RE: Setting file server time

 Since the advent of NTP on the Windows platforms I
don't
 remember the last time there was a need to set the
time manually :-)

 Thanks- T

 -Original Message-
 From: Howard Tanner [mailto:tan...@optonline.net]
 Sent: Monday, September 26, 2011 5:26 PM
 To: Tobias Hoellrich; 'Barry Brevik';
 perl-win32-users@listserv.ActiveState.com
 Subject: RE: Setting file server time

 NET TIME was my first thought too, but it only allows
you to
 set your time to that of another machine.

 ___
 Perl-Win32-Users mailing list
 Perl-Win32-Users@listserv.ActiveState.com
 To unsubscribe:
http://listserv.ActiveState.com/mailman/mysubs


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe:
http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe:
http://listserv.ActiveState.com/mailman/mysubs

RE: Setting file server time

2011-09-27 Thread David J Effa
You can't make use of this:  http://support.microsoft.com/kb/816042

-Dave

perl-win32-users-boun...@listserv.activestate.com wrote on 09/26/2011 
07:23:59 PM:

 [image removed] 
 
 RE: Setting file server time
 
 Barry Brevik 
 
 to:
 
 Tobias Hoellrich, Howard Tanner, perl-win32-users
 
 09/26/2011 07:22 PM
 
 Sent by:
 
 perl-win32-users-boun...@listserv.activestate.com
 
 Yes NTP. Well, if the guy had it setup right it would work, but no. So I
 had to create an internet time server bot (with a little help) which
 sets the local machine time. I was hoping to employ a Win32-only
 solution to then set the domain controller rather than spawn one of the
 pstools (I am familiar with them).
 
 
  -Original Message-
  From: perl-win32-users-boun...@listserv.activestate.com 
  [mailto:perl-win32-users-boun...@listserv.activestate.com] On 
  Behalf Of Tobias Hoellrich
  Sent: Monday, September 26, 2011 4:44 PM
  To: Howard Tanner; perl-win32-users@listserv.ActiveState.com
  Subject: RE: Setting file server time
  
  Since the advent of NTP on the Windows platforms I don't 
  remember the last time there was a need to set the time manually :-)
  
  Thanks- T
  
  -Original Message-
  From: Howard Tanner [mailto:tan...@optonline.net]
  Sent: Monday, September 26, 2011 5:26 PM
  To: Tobias Hoellrich; 'Barry Brevik'; 
  perl-win32-users@listserv.ActiveState.com
  Subject: RE: Setting file server time
  
  NET TIME was my first thought too, but it only allows you to 
  set your time to that of another machine. 
  
  ___
  Perl-Win32-Users mailing list
  Perl-Win32-Users@listserv.ActiveState.com
  To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
  
  
 ___
 Perl-Win32-Users mailing list
 Perl-Win32-Users@listserv.ActiveState.com
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Setting file server time

2011-09-27 Thread William . Hoopes
I've used Win32-OLE to start/execute processes on remote computers.  In
this scenario you could use Win32-OLE to call time



-Original Message-
From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Barry Brevik
Sent: Monday, September 26, 2011 8:24 PM
To: Tobias Hoellrich; Howard Tanner;
perl-win32-users@listserv.ActiveState.com
Subject: RE: Setting file server time

Yes NTP. Well, if the guy had it setup right it would work, but no. So I
had to create an internet time server bot (with a little help) which
sets the local machine time. I was hoping to employ a Win32-only
solution to then set the domain controller rather than spawn one of the
pstools (I am familiar with them).


 -Original Message-
 From: perl-win32-users-boun...@listserv.activestate.com 
 [mailto:perl-win32-users-boun...@listserv.activestate.com] On 
 Behalf Of Tobias Hoellrich
 Sent: Monday, September 26, 2011 4:44 PM
 To: Howard Tanner; perl-win32-users@listserv.ActiveState.com
 Subject: RE: Setting file server time
 
 Since the advent of NTP on the Windows platforms I don't 
 remember the last time there was a need to set the time manually :-)
 
 Thanks- T
 
 -Original Message-
 From: Howard Tanner [mailto:tan...@optonline.net]
 Sent: Monday, September 26, 2011 5:26 PM
 To: Tobias Hoellrich; 'Barry Brevik'; 
 perl-win32-users@listserv.ActiveState.com
 Subject: RE: Setting file server time
 
 NET TIME was my first thought too, but it only allows you to 
 set your time to that of another machine. 
 
 ___
 Perl-Win32-Users mailing list
 Perl-Win32-Users@listserv.ActiveState.com
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
 
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Setting file server time

2011-09-26 Thread Barry Brevik
Using Perl 5.8.8.
 
I have both of the Win32 books and I've googled for this but I've come
up short.
 
Does anyone know how to set the time on a Windows server from a remote
machine?
 
Barry Brevik
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Setting file server time

2011-09-26 Thread Tobias Hoellrich
Also take a look at net time: 
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/net_time.mspx?mfr=true

Cheers - T

-Original Message-
From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Howard 
Tanner
Sent: Monday, September 26, 2011 5:08 PM
To: 'Barry Brevik'; perl-win32-users@listserv.ActiveState.com
Subject: RE: Setting file server time

You can use the DOS TIME command to set the time (it uses military time). To 
execute it on a remote computer, I recommend psexec from Sysinternals. The 
advantage of psexec is you don't have to install anything on the remote machine 
- pstools installs itself there automatically if it needs to (and you have 
admin rights on the machine). psexec isn't available on its own, you have to 
download the entire command line suite, called pstools:

http://download.sysinternals.com/Files/PsTools.zip

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Setting file server time

2011-09-26 Thread Howard Tanner
NET TIME was my first thought too, but it only allows you to set your time
to that of another machine.

-Original Message-
From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Tobias Hoellrich
Sent: Monday, September 26, 2011 7:12 PM
To: 'Barry Brevik'; perl-win32-users@listserv.ActiveState.com
Subject: RE: Setting file server time

Also take a look at net time:
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-
us/net_time.mspx?mfr=true

Cheers - T

-Original Message-
From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Howard Tanner
Sent: Monday, September 26, 2011 5:08 PM
To: 'Barry Brevik'; perl-win32-users@listserv.ActiveState.com
Subject: RE: Setting file server time

You can use the DOS TIME command to set the time (it uses military time). To
execute it on a remote computer, I recommend psexec from Sysinternals. The
advantage of psexec is you don't have to install anything on the remote
machine - pstools installs itself there automatically if it needs to (and
you have admin rights on the machine). psexec isn't available on its own,
you have to download the entire command line suite, called pstools:

http://download.sysinternals.com/Files/PsTools.zip

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Setting file server time

2011-09-26 Thread Howard Tanner
You can use the DOS TIME command to set the time (it uses military time). To
execute it on a remote computer, I recommend psexec from Sysinternals. The
advantage of psexec is you don't have to install anything on the remote
machine - pstools installs itself there automatically if it needs to (and
you have admin rights on the machine). psexec isn't available on its own,
you have to download the entire command line suite, called pstools:

http://download.sysinternals.com/Files/PsTools.zip


-Original Message-
From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Barry Brevik
Sent: Monday, September 26, 2011 5:24 PM
To: perl-win32-users@listserv.ActiveState.com
Subject: Setting file server time

Using Perl 5.8.8.
 
I have both of the Win32 books and I've googled for this but I've come up
short.
 
Does anyone know how to set the time on a Windows server from a remote
machine?
 
Barry Brevik
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Setting file server time

2011-09-26 Thread Tobias Hoellrich
Since the advent of NTP on the Windows platforms I don't remember the last time 
there was a need to set the time manually :-)

Thanks- T

-Original Message-
From: Howard Tanner [mailto:tan...@optonline.net] 
Sent: Monday, September 26, 2011 5:26 PM
To: Tobias Hoellrich; 'Barry Brevik'; perl-win32-users@listserv.ActiveState.com
Subject: RE: Setting file server time

NET TIME was my first thought too, but it only allows you to set your time
to that of another machine. 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Setting file server time

2011-09-26 Thread Barry Brevik
Yes NTP. Well, if the guy had it setup right it would work, but no. So I
had to create an internet time server bot (with a little help) which
sets the local machine time. I was hoping to employ a Win32-only
solution to then set the domain controller rather than spawn one of the
pstools (I am familiar with them).


 -Original Message-
 From: perl-win32-users-boun...@listserv.activestate.com 
 [mailto:perl-win32-users-boun...@listserv.activestate.com] On 
 Behalf Of Tobias Hoellrich
 Sent: Monday, September 26, 2011 4:44 PM
 To: Howard Tanner; perl-win32-users@listserv.ActiveState.com
 Subject: RE: Setting file server time
 
 Since the advent of NTP on the Windows platforms I don't 
 remember the last time there was a need to set the time manually :-)
 
 Thanks- T
 
 -Original Message-
 From: Howard Tanner [mailto:tan...@optonline.net]
 Sent: Monday, September 26, 2011 5:26 PM
 To: Tobias Hoellrich; 'Barry Brevik'; 
 perl-win32-users@listserv.ActiveState.com
 Subject: RE: Setting file server time
 
 NET TIME was my first thought too, but it only allows you to 
 set your time to that of another machine. 
 
 ___
 Perl-Win32-Users mailing list
 Perl-Win32-Users@listserv.ActiveState.com
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
 
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs