8

I understand that I can query system time of my machine like this:

from datetime import datetime
datetime.now()

Is there a way to query the system time of another machine on the windows network? Eg of \\mynetworkpc.

bluish
  • 26,356
  • 27
  • 122
  • 180
SIndhu
  • 677
  • 3
  • 15
  • 21

2 Answers2

6

on a Windows machine there is net time \\<remote-ip address> to get the time of a remote machine but I don't know if it is portable.

>>> import subprocess
>>> subprocess.call(r"net time \\172.21.5.135")
Current time at \\172.21.5.135 is 10/18/2010 12:32 PM

The command completed successfully.

0
>>>
anijhaw
  • 8,954
  • 7
  • 35
  • 36
  • this works for me. In addition to ip address, you could also use the machine name, both work fine.. Thanks ! – SIndhu Oct 18 '10 at 17:01
0

You could combine a Python WMI module with the answers to this question: get-remote-pcs-date-time

Community
  • 1
  • 1
phoebus
  • 14,673
  • 2
  • 33
  • 35