advanced vbscript question

Posted on 2006-05-17
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
    LVL 3

    Accepted Solution

    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(,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

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Suggested Solutions

    I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
    Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
    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 seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    731 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now