Solved

Setting system time from another machine

Posted on 2002-06-05
6
165 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 1

Expert Comment

by:Toad224
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article will show, step by step, how to integrate R code into a R Sweave document
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

743 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

10 Experts available now in Live!

Get 1:1 Help Now