Iterate through Nested Directories Using Windows Scripting Host

Category:
Files and Directories
Type:
Snippets
Difficulty:
Beginning
Author:
Ron Olson

Version Compatibility:

More information:
This is a vbscript function that will display nested directories in a tree-like fashion, similar to Windows Explorer. Right now, it just pops up a message box with the name of the subdirectory and symbols indicated its level of nesting, but it can easily be modified to do something more useful.

To run this using Windows Scripting Host, save this as a .vbs file on a system with WSH installed, and call it from the command line. You can pass a parameter indicating what subdirectory you want as the top-level; otherwise, it will use the current subdirectory as the default.

Instructions: Copy the declarations and code below and paste directly into your VB project.

Declarations:

Code: