Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


newbie - Searching for a file and outputing the results to a msgbox

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

 

 
  
  Printable Version
All Forums >> [General Forum] >> Other Programming/Scripting Languages >> newbie - Searching for a file and outputing the results to a msgbox
  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 >>
 newbie - Searching for a file and outputing the results... - 7/25/2005 2:57:10 AM   
  robertmckee14

 

Posts: 3
Score: 0
Joined: 7/25/2005
Status: offline
I need a script that will return an error message to a msgbox.  basically if an error occurs the errormsg.txt file will contain an error msg otherwise it will be empty. so if the app fails i need to search through several directories for an errormsg.txt that isnt empty and output the contents of the file to a msgbox. 

the output of a file to a msgbox is easy but the searching for a non empty errormsg.txt i cant do.  the path for the search is along the lines of...

\project\*\_errormsg.txt

as there are many steps within each project that each have there own directory and could contain the non empty file.

Any advice?!
 
 
Post #: 1
 
 RE: newbie - Searching for a file and outputing the res... - 7/25/2005 10:29:09 AM   
  Country73


Posts: 712
Score: 8
Joined: 8/25/2004
From: USA
Status: offline
Welcome to the VBScript Forum!

Are you wanting to add a step inside of your script to where it will display the error in a msgbox while also creating your errormsg.txt?
Or are you looking for a script that will search for the errormsg.txt and then pull the information out into a msgbox?


(in reply to robertmckee14)
 
 
Post #: 2
 
 RE: newbie - Searching for a file and outputing the res... - 7/26/2005 12:39:40 AM   
  robertmckee14

 

Posts: 3
Score: 0
Joined: 7/25/2005
Status: offline
HI,

The 2nd one. I want to search for the _errormsg.txt which has already been created by the application read the text from it and display it in a msgbox. The _errormsg.txt that i will need to read and display is identified by the fact that its not empty.

Havent been able to get it workin!!

(in reply to Country73)
 
 
Post #: 3
 
 RE: newbie - Searching for a file and outputing the res... - 7/26/2005 3:15:24 AM   
  Country73


Posts: 712
Score: 8
Joined: 8/25/2004
From: USA
Status: offline
If the one you have now is not working, can you show what you're using?
(May just need to tweak the one you have instead of re-creating it)

(in reply to robertmckee14)
 
 
Post #: 4
 
 RE: newbie - Searching for a file and outputing the res... - 7/26/2005 8:00:19 PM   
  robertmckee14

 

Posts: 3
Score: 0
Joined: 7/25/2005
Status: offline
im back to square one im afraid as i deleted the code as i was goin along, as after an hour or so of playing around with it, things were starting to get a little messy to say the least!

(in reply to Country73)
 
 
Post #: 5
 
 RE: newbie - Searching for a file and outputing the res... - 7/28/2005 12:38:25 AM   
  Country73


Posts: 712
Score: 8
Joined: 8/25/2004
From: USA
Status: offline
Sorry for the delay in getting back to you.

I'll see what I can do on throwing a script together to search through folders until it finds the "errormsg.txt", then check to see if the errormsg.txt is blank or not.

Hopefully it won't take too long to throw this together, just as long as things don't get too overwhelming here at work.

Country73

(in reply to robertmckee14)
 
 
Post #: 6
 
 RE: newbie - Searching for a file and outputing the res... - 7/28/2005 1:08:39 AM   
  Country73


Posts: 712
Score: 8
Joined: 8/25/2004
From: USA
Status: offline
OK, this should take care of it for you. This script was supplied by Xandros, here at the forum, which I just had to do a little modification on.
The only thing you should have to do is change the directory path.

'---------------------------------------------------------------------------------------------------
Set fso = CreateObject("Scripting.FileSystemObject")
Const FIL = "errormsg.txt"                    'File we are looking for
DirWalk("C:\Documents and Settings")  'Change this to what you need

Sub DirWalk(parmPath)
   On Error Resume Next
   Set oSubFolder = fso.getfolder(parmPath)
       For Each oFile In oSubFolder.Files   ' look in the current dir
           If Err.Number <> 0 Then             ' if we get an error, just skip this entry
               Err.Clear
           ElseIf oFile.Name = FIL Then
           Set g = fso.GetFile(oFile)
           Set R = g.OpenAsTextStream(1,TristateUseDefault)
               Do While R.AtEndOfStream <> True
                   myMsg = myMsg & R.ReadLine & vbcrlf     'File contents
               Loop
               myLocal = oFile.Path               'Tell us where the file is located
               Wscript.Echo myLocal & vbcrlf & vbcrlf & myMSG
           End If 
       Next
       For Each oSubDir In oSubFolder.Subfolders
          DirWalk oSubDir.Path                  ' recurse the DirWalk sub with the subdir paths
        Next
       On Error Goto 0                              ' Resume letting system handle errors.
End Sub

wscript.echo "Done searching"
'---------------------------------------------------------------------------------------------------

Let us know if this works out for you or not.
Country73

(in reply to robertmckee14)
 
 
Post #: 7
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [General Forum] >> Other Programming/Scripting Languages >> newbie - Searching for a file and outputing the results to a msgbox 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