|
The purpose of the script I am trying to write is to:
- Check 2 local (c drive) files on user log on Note: all PCs will have file1.txt present; some (not all) will also have file2.txt present
Report details of file1 and file2 (time & date) to a text log files auditfile1.txt and auditfile2.txt respectively. (stored on network drive - users have access)
Note: this will be performed on user log-on, so none of the text files mentioned will be open.
I have tried to follow the high level process of:
1 - Create a timestamp (may not be necessary, but I may want to use this later) 2 - Get file time / dates for file1.txt and file2.txt 3 - Open auditfile1 4 - write line in auditfile1 5 - Close auditfile 1 6 - Repeat steps 3-5 for auditfile2 7 - end script
auditfile1.txt and auditfile2.txt are both created and in place; but I cannot get an entry to appear in either. For reference, the version of kixtart currently used is 3.60.0.0. Here's my try so far: I'd be grateful for any help offered -------------------------------------------
; * Create the TIMESTAMP ; a TIMESTAMP is not strictly necessary!
IF @MONTHNO < 10 $MONTH= "0" + "@MONTHNO" ELSE $MONTH= "@MONTHNO" ENDIF
IF @MDAYNO < 10 $DAY= "0" + "@MDAYNO" ELSE $DAY= "@MDAYNO" ENDIF
$timestamp = "@YEAR" + "-" + "$MONTH" + "-" + "$DAY" + " " + @TIME $ComputerName = @WKSTA
; ------------------------------------------------------------------------ ; * Create an antry in auditfile1 or auditfile2 relating to date held for ;C:\program files\file1.txt and c:\ program files\file2.txt respectively ; ------------------------------------------------------------------------
$logfile1 = "I:\foldername\auditfile1.txt." $logfile2 = "I:\foldername\auditfile2.txt"
$Result1 = GetFileTime("$C:\program files\file1.txt") $Result2 = GetFileTime("$C:\program files\file2.txt")
$ = Open ($logfile1)
if len($Result1)>0 $Result1string = "$TIMESTAMP;$ComputerName;$Result1" $x = WriteLine( 3 , $Result1string + Chr(13) + Chr(10) ) endif
$ = Close ($logfile1)
$ = Open ($logfile2)
if len($Result2)>0 $Result2string = "$TIMESTAMP;$ComputerName;$Result2" $x = WriteLine( 3 , $Result2string + Chr(13) + Chr(10) ) endif
$ = Close ($logfile2)
exit _________________ Thanks Beejay
|