title: VBS Creating CSV file then adding extra rows to it
body: <p>Below is my VBS code. I will admit, I am extremely new to this since I was give this as a job at work. I need to create a logon/logoff script that will capture certain information and store it in a csv file. I am able to get the information and store it in the csv file, but when I try to do it again, I want it to create another row and store the updated information there. I keep getting these asian characters. What seems to be the problem. </p>
  
  <p>This is what I get on the second time I click my log off script:
  ਍潙牵琠硥⁴潧獥栠牥⹥਍</p>
  
  <pre><code>' ******************** Log Off Script **********************************
  'Script to write Logoff Data Username, Computername to eventlog.
  
  Dim objShell, WshNetwork, PCName, UserName, strMessage, strContents, logDate, logTime
  Dim strQuery, objWMIService, colItems, strIP, rowCount
  
  ' Constants for type of event log entry
  const EVENTLOG_AUDIT_SUCCESS = 8
  
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objShell = CreateObject("WScript.Shell")
  Set WshNetwork = WScript.CreateObject("WScript.Network")
  
  logDate = Date()
  logTime = Time()
  PCName = WshNetwork.ComputerName 
  UserName = WshNetwork.UserName  
  strMessage = "Logoff Event Data" &amp; "PC Name: " &amp; PCName &amp; "Username: " &amp; UserName &amp; "Date: " &amp; logDate &amp; "Time: " &amp; logTime
  
  If (objFSO.FileExists("test.csv")) Then
  WScript.Echo("File exists!")
  dim filesys, filetxt 
  Const ForReading = 1, ForWriting = 2, ForAppending = 8 
  Set filesys = CreateObject("Scripting.FileSystemObject") 
  Set filetxt = filesys.OpenTextFile("test.csv", ForAppending, True) 
  filetxt.WriteLine(vbNewline &amp; "Your text goes here.") 
  filetxt.Close 
  
  Else
  rowCount = rowCount + 1
  WScript.Echo("File does not exist! File Created!")
  Set csvFile = objFSO.CreateTextFile("test.csv", _ 
  ForWriting, True)
  
  objShell.LogEvent EVENTLOG_AUDIT_SUCCESS, strMessage
  csvFile.Write strMessage
  csvFile.Writeline
  
  End If  
  
  WScript.Quit
  </code></pre>