Erla,
Try this:
Dim objFSO, FilePointer, TheFileName
set objFSO= CreateObject("Scripting.FileSystemObject")
TheFileName = user & ".txt"
' This will create the file if it does not exist.
If objFSO.FileExists(TheFileName) then
set FilePointer = objFSO.CreateTextFile(TheFileName, True)
FilePointer.Close
End If
'Otherwise you will open the file just for appending to it
Set FilePointer = objFSO.OpenTextFile(TheFileName, ForAppending)
FilePointer.WriteLine("USERNAME= " & user & " I.P = "& address & " TIME= " &
Date & "WORKSTATION= " & computer)
FilePointer.Close
set objFSO = Nothing
---
Note that you will need to include methods from the wscript.shell object in
order to obtain the IP address of the
machine where the user is working.
Quote:
> I need help!!! I am not able to append to this file i am creating. This is
a
> log file but everytime i run it, it overwrites the contents of the file.
> Here is the code:
> const ForWriting = 2
> const ForReading = 1
> const ForAppending = 8
> Dim oFA
> set oFA = wscript.createObject("scripting.filesystemobject")
> oFA.createtextfile user & ".txt"
> file = user & ".txt"
> set f = oFA.opentextfile (file, ForAppending, false)
> f.write "USERNAME= " & user & " I.P = "& address & " TiME= " & Date & "
> WORKSTATION= " & computer & chr(10) & chr(13)
> f.close
> Set oFA = nothing
> Thanks!!!