Solved

Setting system time from another machine

Posted on 2002-06-05
6
166 Views
Last Modified: 2013-11-13
I need to set my workstations' time from a local server, and the local server's date & time from a remote server over a WAN connection.  Any ideas on how this can be achieved
0
Comment
Question by:barendb
6 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 100 total points
ID: 7055868
This sample will allow you to determine the data and time on a remote machine:

http://www.btinternet.com/~vbadmincode/code/netremotetod.zip

With this you can then use this API call to set the system date and time.

Private Type SYSTEMTIME
    wYear As Integer
    wMonth As Integer
    wDayOfWeek As Integer
    wDay As Integer
    wHour As Integer
    wMinute As Integer
    wSecond As Integer
    wMilliseconds As Integer
End Type
Private Declare Function SetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME) As Long
Private Sub Form_Load()
    'KPD-Team 2000
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net
    Dim lpSystemTime As SYSTEMTIME
    lpSystemTime.wYear = 2000
    lpSystemTime.wMonth = 1
    lpSystemTime.wDayOfWeek = -1
    lpSystemTime.wDay = 24
    lpSystemTime.wHour = 23
    lpSystemTime.wMinute = 26
    lpSystemTime.wSecond = 0
    lpSystemTime.wMilliseconds = 0
    'set the new time
    SetSystemTime lpSystemTime
End Sub
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 7056446
Need some help with maintaining your open questions or do you have no interest in following up?  For the record:

Questions Asked 3
Last 10 Grades Given  
Question Grading Record 0 Answers Graded / 0 Answers Received

Anthony
0
 
LVL 1

Author Comment

by:barendb
ID: 7056561
For the record, one of the open questions is pending deletion, has been for the last couple of months.  I've decided to delete it because I did not receive a satisfactory answer.

On the other open question, I've posted a comment to the effect of, the first person to respond, get's the points.   If I don't get a response, I'm not going to award points.

As for this question, I'm busy testing Tim's solution and will accept his answer as soon as I've had time to finish testing.

So to answer your question, No I don't need help in maintaining my questions, and I am interested in what happens with them.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Expert Comment

by:Toad224
ID: 7056819
I assume they're Windows machines if you're looking to use VB.  Windows workstations can have logon scripts that are set by a server.  You should look into using    "net time /set"  for synchronizing the time.  Try typing "net help time" in a command prompt window.  A Windows NT (NT4, 2000 or XP) server should have the Windows Time service activated.

If you really want to use VB, you should look into the WinAPI function SetSystemTime and winsock.

I hope this helps.  Good luck!
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 7058352
You may want to contact Community Support (http://www.experts-exchange.com/commspt/), both questions are showing "Waiting for Answer":

Remote Access Services Problem Date: 03/14/2001 02:20AM PST
http://www.experts-exchange.com/jsp/qShow.jsp?ta=networkgen&qid=20091389
SQL Server connection error Date: 07/19/2001 03:19AM PST  
http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20153431

Anthony
0
 
LVL 1

Author Comment

by:barendb
ID: 7058618
Anthony,

I totally forgot about the remote access services question, which does not show under the VB section, where I spend 99% of my time.  I'll go and grade it now.  As for this one, Tim get's the points will also award them now.

Toad 224, thanks for the suggestion, but these machines almost never get rebooted and I need their tiem set on a regular basis.  So the points go to Tim

Barend
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now