[Last Call] Learn how to a build a cloud-first strategyRegister Now


How to list all files using dir + switch

Posted on 2006-05-23
Medium Priority
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

ID: 16747948
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

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

Accepted Solution

EDDYKT earned 100 total points
ID: 16750356
what happen if you wait for it to finish

ie change the last arg to true

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses
Course of the Month17 days, 17 hours left to enroll

830 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