Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Edit textfile

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,64996
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Edit textfile
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Edit textfile - 10/12/2008 4:38:42 PM   
  Frobs

 

Posts: 16
Score: 0
Joined: 9/22/2008
Status: offline
Hi

I have created a new VB login script and I would like to create a errorlog during the script. Each time my procedure for writing to the errorlog is called I transfer a errormessage to it. If I get to errormessages during the login script it only writes the last error, how can I create a logfile the first time the errorlog procedure is called and then only edit it if called again?

I hope this makes sense.

/Frobs
 
 
Post #: 1
 
 RE: Edit textfile - 10/12/2008 5:12:59 PM   
  TomRiddle


Posts: 188
Score: 4
Joined: 2/7/2008
Status: offline
This sub will append the log file



      



http://www.google.com.au/search?hl=en&q=vbscript+OpenTextFile+syntax

(in reply to Frobs)
 
 
Post #: 2
 
 RE: Edit textfile - 10/12/2008 8:49:01 PM   
  Frobs

 

Posts: 16
Score: 0
Joined: 9/22/2008
Status: offline
Hi

It worked like a charm. I don't know how I missed the OpenTextFile parameter, I found it right away after reading your reply :-)

My script is now registering each error message and appending them to the logfile.

Thanks for your help!

/Frobs

(in reply to TomRiddle)
 
 
Post #: 3
 
 RE: Edit textfile - 10/13/2008 10:14:16 AM   
  TomRiddle


Posts: 188
Score: 4
Joined: 2/7/2008
Status: offline
Glad I could help.

(in reply to Frobs)
 
 
Post #: 4
 
 RE: Edit textfile - 10/13/2008 11:00:49 PM   
  mbouchard


Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
You could even take this one step further and timestamp it.

WriteLog "log.txt", "This is an error logged"

sub WriteLog(strLog, StrContent)
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.OpenTextFile(strLog, 8, True).WriteLine Now() & " - " & strContent
End Sub

_____________________________

Mike

For useful Scripting links see the Read Me First stickey!

Always remember Search is your friend.

(in reply to TomRiddle)
 
 
Post #: 5
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Edit textfile Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts