• Photos Photos
  • Linked In Linked In
  • Google + Google +
  • Facebook Facebook
  • Flickr Flickr
  • Vimeo Vimeo

www.gavinwill.me.uk

Photography, IT, Bikes and more.

  • Pages

    • About
    • Blog
    • Contact
    • Home
  • Archives

    • January 2013
    • September 2012
    • August 2012
    • July 2012
    • June 2012
    • May 2012
    • April 2012
    • March 2012
    • February 2012
    • January 2012
    • December 2011
    • November 2011
  • Search:

Posts

  • View Archive

Get Time From Remote Windows PC

I noticed some drift on our server from the correct time from NTP. After resyncing I wanted to ensure the clients were updated also. I didnt want to interrupt the users so I used a VBScript to remotely get the time from a specific computer. Just specify the computer name and run the VBS:

strComputer = "computername"
 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
 
Set colItems = objWMIService.ExecQuery("Select * From Win32_LocalTime")
 
For Each objItem in colItems
    strTime = objItem.Hour & ":" & objItem.Minute & ":" & objItem.Second
    dtmTime = CDate(strTime)
    Wscript.Echo FormatDateTime(dtmTime, vbFormatLongTime)
Next

strComputer = "computername" Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * From Win32_LocalTime") For Each objItem in colItems strTime = objItem.Hour & ":" & objItem.Minute & ":" & objItem.Second dtmTime = CDate(strTime) Wscript.Echo FormatDateTime(dtmTime, vbFormatLongTime) Next

  • December 13, 2011
  • Windows
  • 0
Cancel Reply

Copyright © 2021 www.gavinwill.me.uk.

  • LinkedIn
  • Google +
  • Facebook
  • Flickr
  • Vimeo
Back to Top