Jump to content

Time, Registry, & Remote machines... oh my


KXM
 Share

Recommended Posts

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

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

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

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

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?

Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...