Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Updating local machines on a network

Posted on 1998-07-29
1
Medium Priority
?
256 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 150 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

618 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