Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Writing to a text file (should be easy...)

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Writing to a text file (should be easy...)
  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 >>
 Writing to a text file (should be easy...) - 7/28/2004 2:50:26 AM   
  cobolexpert

 

Posts: 7
Score: 0
Joined: 7/22/2004
From:
Status: offline
Hey everyone,
I was wondering if someone could check out this script I made. It's a wscript vbscript that checks to see if someone is using certain locations on two servers, if not it copies files from one location to another and then compares the directories to make sure the copy went alright. I am having a small problem with my log though. The log writes just fine the first couple times but then errors out on one of the writes. Doesn't make any sense to me... Here is the error:

Line 349, Char 2, Object doesn't support this property or method: 'oFileObject.OpenTextFile'

I can only get the error to show up if I comment out some lines dealing with spreadsheets (because they need the on error resume next line). I bolded those lines as well as the specific write that is giving me problems. If you take a close look at the script, you can see that I have already written to the log three times. I am trying to figure out why it would error out on something it already did sucessfully multiple times...

Here's the code. Any ideas??? THANKS! - JB




      
 
 
Post #: 1
 
 Re: Writing to a text file (should be easy...) - 7/29/2004 1:22:20 AM   
  mbouchard


Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
Some things that look wrong to me.

1-Right before you get to the commented text you set this.
Set oFSO = GetObject("WinNT://" & sServer & "/LanmanServer")

2-Use this line several places
Set oFso = CreateObject("Scripting.FileSystemObject")


3-Line where you get your error, you are passing oFSO to the writelog sub but right before you are setting oFSO to #1 and are using oFileObject to open the text file.
Call WriteLog(sLog, sLogMessage, oFSO)

4-This is set inside of createlog, do not think it is ever dim'd
Set oFileObject = CreateObject("Scripting.FileSystemObject")

Some recomendations:

- Set oFSO at the top of the script when you dim it ex., remove from all subs/functions and pass it like you are doing with the writelog sub.
Dim oFSO : Set oFso = CreateObject("Scripting.FileSystemObject")

-Change this to something else.
Set oFSO = GetObject("WinNT://" & sServer & "/LanmanServer")

-Use oFSO instead of oFileObject.

(in reply to cobolexpert)
 
 
Post #: 2
 
 Re: Writing to a text file (should be easy...) - 7/30/2004 3:59:14 AM   
  cobolexpert

 

Posts: 7
Score: 0
Joined: 7/22/2004
From:
Status: offline
Hey,
Thanks for the reply. You are right on, I actually found what you pointed out a little while after I posted. I was setting oFso to something different in the middle of my script so that when it went to write the log at a certain point and use oFso, it was not at the correct setting. I changed the one 'getobject' set to be oLso (Lanmanserver Service Object) instead of oFso for it to make more sense and tada, all my logs work fine now. Thanks for the help!!

(in reply to cobolexpert)
 
 
Post #: 3
 
 Re: Writing to a text file (should be easy...) - 7/30/2004 7:38:42 AM   
  mbouchard


Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
Glad I can help.

(in reply to cobolexpert)
 
 
Post #: 4
 
 
 
  

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 >> Writing to a text file (should be easy...) 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