Solved

Updating local machines on a network

Posted on 1998-07-29
1
241 Views
Last Modified: 2013-11-13
I,m looking for a simple routine that compares the file dates of a single file on both a server and a local machine and if the date on the server is newer than the local machine will copy the file over, overwriting the old one, Any clues ??? p.s. i am new to V.B.
0
Comment
Question by:cs9ue
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 14

Accepted Solution

by:
waty earned 50 total points
ID: 1467039
You could use the Robocopy application wich come with the NT ressource kit and is the same than the "rdist" command under Unix.

Other wise, you have to do as following :

Public Sub Robocopy(sServer As String, sLocal As String)
   ' *** Maintain same files from a Server to a lical drive
   
   Dim sFile         As String

   sFile = Dir(sServer)

   Do While (sFile <> "")
      ' *** Test if the file exists
      If Existfile(sFile) = False Then
         ' *** Does not exists
         FileCopy sServer & "\" & sFile, sLocal & "\" & sFile
         
         GoTo NEXT_FILE
      End If
     
      ' *** The file exists
     
      ' *** Verify the size
      If FileLen(sServer & "\" & sFile) <> FileLen(sLocal & "\" & sFile) Then
         ' *** Not the same size
         FileCopy sServer & "\" & sFile, sLocal & "\" & sFile
         
         GoTo NEXT_FILE
      End If
     
      ' *** Verify the date
      If FileDateTime(sServer & "\" & sFile) <> FileDateTime(sLocal & "\" & sFile) Then
         ' *** Not the same date/time
         FileCopy sServer & "\" & sFile, sLocal & "\" & sFile
         
         GoTo NEXT_FILE
      End If
     
NEXT_FILE:
      sFile = Dir()
   Loop

End Sub

0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

705 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