Hello,
I have a log that I use during logon that captures certain information (time/date, computer name, user name, ip and mac address etc. and has been working well for me to date. However, I have had need on occasion to use these routines for other tasks I was assigned to do. I need to be able to (of course) log each login event, however, I would like it to search for a previous entry (via computer name) and instead of creating a new entry, to modify the previous entry with new logon information, and I am not sure how to accomplish this. Can you provide me with a way to update an existing entry based upon the computer name?
Here is some of the code I'm using at the moment, its pretty basic but gets the job done.
SubLogIt()
Path="\\Server\share\Logon Info.csv"
ConstForReading=1
ConstForWriting=2
ConstForAppending=8
Iffso.FileExists(Path)=0Then
'LogFilenotfound-CreateLogFile
SetoFile=fso.CreateTextFile(Path,True)
oFile.WriteLine("Date&Time"&","&"ComputerName"&","&"NTUserID"&","&"FirstName"&","&"LastName"&","&"OperatingSystem"&","&"Version"&","&"IP
Address"&","&"Mac Address"&vbCrLf)
oFile.Close
WScript.Sleep(500)
EndIf
SetoFile=fso.OpenTextFile(Path,ForAppending)
oFile.Write(Now()&","&strComputer&","&strUserName&","&strGivenName&","&oUser.sn&","&strCaption&","&strArch&","&strIP&","&strMac&vbCrLf)
oFile.Close
EndSub
Any help would be appreciated.