General discussion

Locked

Logon scripts

By Rosiebo ·
I want to roll out an upgrade to some software on an NT based network. The upgrade replaces files that already exist and doesn't add any new ones so I can't use the if exists command. The only difference to the files being copied/replaced is the modify date. What command can I use in the logon script to check for a modify date.

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by ChrisDent In reply to Logon scripts

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 = "<local file name and path>"
$ServerFile = "<remote file name and path>"
$LocalPath = "<local path>"
$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

Collapse -

by martin In reply to Logon scripts
Collapse -

by Cookie_Monster In reply to Logon scripts

Look at using XCopy.

Xcopy /? from a command line will give you all available switches.

You will probably need /U and /D

Back to Networks Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums