How to list all files using dir + switch

Posted on 2006-05-23
Last Modified: 2010-08-05
i created a vbs file to list all files in the directories, but it gives a list of all files on 1 drive and on another drives just a half of files.
I'm using %compsec%.  Can someone give a solution?

My code:

objShell.Run "%comspec% /c " & Chr(34) & "dir d:\ /a:-d /s /n /t:W >\\server\Drive_c.txt" &_ Chr(34), 0, false
objShell.Run "%comspec% /c " & Chr(34) & "dir e:\ /a:-d /s /n /t:W >\\server\Drive_e.txt" &_ Chr(34), 0, false
objShell.Run "%comspec% /c " & Chr(34) & "dir f:\ /a:-d /s /n /t:W >\\server\Drive_f.txt" & _Chr(34), 0, false

Set WS = CreateObject("Wscript.Shell")

Question by:jefmelkenbeek

    Author Comment

    More explanation:
    in this code, the vbs file will list all files of drives (d:, e:, f:) using compsec with dir + switch
    (d:\ /a:-d /s /n /t:W). The result is, exp: the script list everything of drive e:, but 2 others just a half.
    LVL 19

    Expert Comment

    afer checking everything over, it looks fine..very strange.
    LVL 26

    Accepted Solution

    what happen if you wait for it to finish

    ie change the last arg to true

    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

    The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
    This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    728 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