KXM Posted October 5, 2005 Share Posted October 5, 2005 Quick question, is it possable to get the time from a remote machine on my LAN, and use it to set the time on local machine. I quess what I'm asking is where are the Windows Time registry settings (if any)? Any help is great! TIA. Link to comment Share on other sites More sharing options...
BigDod Posted October 5, 2005 Share Posted October 5, 2005 Quick question, is it possable to get the time from a remote machine on my LAN, and use it to set the time on local machine.I quess what I'm asking is where are the Windows Time registry settings (if any)?Any help is great!TIA.You could use PSExec to run the time command on the remote computer then use the result to set the time on the local computer. PSExec is part of PSTools from Sysinternals Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
GaryFrost Posted October 5, 2005 Share Posted October 5, 2005 using beta, change "localhost" to machine name CODE $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output="" $Output = $Output & "Computer: " & $strComputer & @CRLF $Output = $Output & "==========================================" & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems $Output = $Output & "LocalDateTime: " & WMIDateStringToDate($objItem.LocalDateTime) & @CRLF if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop $Output="" Next Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_OperatingSystem" ) Endif Func WMIDateStringToDate($dtmDate) Return (StringMid($dtmDate, 5, 2) & "/" & _ StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _ & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2)) EndFunc SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
KXM Posted October 6, 2005 Author Share Posted October 6, 2005 using beta, change "localhost" to machine nameCODE$wbemFlagReturnImmediately = 0x10$wbemFlagForwardOnly = 0x20$colItems = ""$strComputer = "localhost"$Output=""$Output = $Output & "Computer: " & $strComputer & @CRLF$Output = $Output & "==========================================" & @CRLF$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly)If IsObj($colItems) then For $objItem In $colItems $Output = $Output & "LocalDateTime: " & WMIDateStringToDate($objItem.LocalDateTime) & @CRLF if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop $Output="" NextElse Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_OperatingSystem" )EndifFunc WMIDateStringToDate($dtmDate) Return (StringMid($dtmDate, 5, 2) & "/" & _ StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _ & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2))EndFuncSweet! this retrives the time like a charm... THNX!!!I hate to be more of a bother, but do you know if the is also a com object to set the time on the local unit? Link to comment Share on other sites More sharing options...
BigDod Posted October 6, 2005 Share Posted October 6, 2005 Sweet! this retrives the time like a charm... THNX!!!I hate to be more of a bother, but do you know if the is also a com object to set the time on the local unit?You could always use the DOS command "time" Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
KXM Posted October 6, 2005 Author Share Posted October 6, 2005 Didn't realize there was one, but that'll do wonderfully, as I know nothing of COM. THNX greatly! Link to comment Share on other sites More sharing options...
KXM Posted October 7, 2005 Author Share Posted October 7, 2005 Both systems worked like a charm... Thank you both again. Link to comment Share on other sites More sharing options...
Selmak Posted October 7, 2005 Share Posted October 7, 2005 If it's just a question of synchronising, then net time \\servername /set /yes will work on any Windows LAN. Link to comment Share on other sites More sharing options...
KXM Posted October 7, 2005 Author Share Posted October 7, 2005 HOLY CRAP!!! That rocks! THANK YOU SO VERY MUCH!!!11one 30 lines of code cut down to one.... Sweet! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now