3 replies
by chrisdent
For anything advanced such as that I would recommend Kix Scripts (www.kixtart.org). Kix is a scripting language built for use as in logon scripts and contains many advanced functions including one to achieve exactly what you want.
You'll need to fill in a few details in your script, but in essence this would work:
Logon.bat File:
rem This file is still required to call the logon rem script.
kix32.exe logon.kix
Logon.kix File:
; Logon Script File
;
; Includes functionality to compare the data and
; time attribute of 2 files.
; Since this task is repeated a lot this is a
; function to return a numeric response to
; determine if a file should be overwritten or
; report an error as necessary.
;
; File1 and File2 are passed to this function
; from the main script.
; File1 is the existing file on the computer.
; File2 is the upgrade file from the server.
;
; The responses are: 1 - Server File error
; 2 - Local File does not exist
; 3 - Local File is older than Server File
; 4 - Local File and Server File are the same age
; 5 - Server File is older than Local File
Function FileCheck($File1,$File2)
$Result = COMPAREFILETIMES($File1,$File2)
Select
Case $Result=-3
$FileCheck=1
Case $Result=-2
$FileCheck=2
Case $Result=-1
$FileCheck=3
Case $Result=0
$FileCheck=4
Case $Result=1
$FileCheck=5
EndSelect
EndFunction
; Main Script begins here
$LocalFile = ""
$ServerFile = ""
$LocalPath = ""
$Result = FileCheck($LocalFile,$ServerFile)
If $Result=3
Copy $ServerFile $LocalPath
Endif
You can implement error checking or other others as you wish based around the other values the function can return.
Hope this helps
Chris
Look at using XCopy.
Xcopy /? from a command line will give you all available switches.
You will probably need /U and /D
This discussion is closed to new replies.
Trending Networks posts
Sort by Trending