advanced vbscript question

Posted on 2006-05-17
Medium Priority
Last Modified: 2012-08-14
I have a directory that contains a log file with an unknown name (exept that the extension= .log)
I want a script to be able to open the log file allthough I cannot supply the name of the log file.
Question by:itbabe
1 Comment

Accepted Solution

trainsdse earned 2000 total points
ID: 16698527
This will get the first .log file in the folder.  Put this in a .vbs file and change the path to the folder you want to look in.  Then execute the vbs file from a command prompt to test.

set fso = createobject("scripting.filesystemobject")
set fils = fso.GetFolder("c:\logs").Files
dim s
for each f in fils
    if right(f.name,4)=".log" then
        exit for
    end if
set t = fso.OpenTextFile("c:\logs\" & s)
msgbox t.readline()
set t=nothing
set fso=nothing


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question