![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | line space in log file Hi all, having a few problems with the below script, its part of a bigger script but this is the part we having problems with. It creates the log file with the results, but when you run it agin it overwrites the previos results, is there a way to have the results on each line in the log ? Set objTxtFSO = CreateObject("Scripting.FileSystemObject") strPath = "c:\file.log" Set ObjTxtFile = ObjTxtFSO.OpenTextFile (strPath, ForAppending, False, TristateFalse) objTxtFile.Write(strName & ",") objTxtFile.Write(strServtag & ",") objTxtFile.Write(strSiteName & ",") objTxtFile.Write(strLaptop & ",") objTxtFile.Writeline(strUser) objTxtFile.Close |
My System Specs![]() |
| | #2 (permalink) |
| | Re: line space in log file systemtek schrieb: Quote: > Hi all, having a few problems with the below script, its part of a > bigger script but this is the part we having problems with. > > It creates the log file with the results, but when you run it agin it > overwrites the previos results, is there a way to have the results on > each line in the log ? > > Set objTxtFSO = CreateObject("Scripting.FileSystemObject") > strPath = "c:\file.log" > Set ObjTxtFile = ObjTxtFSO.OpenTextFile (strPath, ForAppending, > False, TristateFalse) > > objTxtFile.Write(strName & ",") > objTxtFile.Write(strServtag & ",") > objTxtFile.Write(strSiteName & ",") > objTxtFile.Write(strLaptop & ",") > objTxtFile.Writeline(strUser) > objTxtFile.Close for me reliably. Does "previous results" mean "last line" or "entire file"? Do you use "On Error Resume Next" and/or "Option Explicit"? In any case: I'd double check the definitions of "ForAppending" and "TristateFalse"; test the script on a new file; test a simple version of the writing: e.g. objTxtFile.Writeline "Geht doch!"; make sure of the datatypes and contents of the str* variables. |
My System Specs![]() |
| | #3 (permalink) |
| | RE: line space in log file > It creates the log file with the results, but when you run it agin it Quote: > overwrites the previos results Quote: > Set ObjTxtFile = ObjTxtFSO.OpenTextFile (strPath, ForAppending, > False, TristateFalse) If you aren't assigning a value to that variable anywhere in your code, then who knows what it is? You can try just using 8, instead. Set ObjTxtFile = ObjTxtFSO.OpenTextFile (strPath, 8 ) [The other two values default to False and TristateFalse, so you really don't need to code them.] Also, you can gain some efficiency (nanoseconds, likely, but still...) by coding your writes all in a single line, thus: Set objTxtFSO = CreateObject("Scripting.FileSystemObject") strPath = "c:\file.log" Set ObjTxtFile = ObjTxtFSO.OpenTextFile(strPath, 8 ) objTxtFile.WriteLine strName & "," & strServtag & "," & strSiteName & "," _ & strLaptop & "," strUser objTxtFile.Close Incidentally, you don't need parentheses with Write or WriteLine. In fact, they are technically incorrect. And, again, will impose a few nanoseconds performance penalty. |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| No line space after issuing ping command on Vista SP1 | Vista General | |||
| Read a line from a text file, without loading the entire file inmemory | PowerShell | |||
| Re: What happeens when you try? Use the big white space under the Subject line and tell us all about it. | Vista mail | |||
| reading a big file line by line to be "out of memory" safe | PowerShell | |||
| "<SPACE> next page; <CR> next line; Q quit" not cleared in console | PowerShell | |||