Here is a little script to get you started with FileSystemObject in conjuction with JScript:
var fso = new ActiveXObject("Scripting.FileSystemObject");
var shell = new ActiveXObject("WScript.Shell");
var path = "%ProgramFiles%";
var programFiles = fso.GetFolder(shell.ExpandEnvironmentStrings(path));
var subFolders = new Enumerator(programFiles.SubFolders);
while (!subFolders.atEnd())
{
var subFolder = subFolders.item();
WScript.Echo(subFolder.Name);
subFolders.moveNext();
}
Call that with csript.exe on the command line:
cscript subfolders.js
The Windows Script 5.6 Documentation holds all the details you need on this topic (and many others). Download it and have it around, it is really helpful. On Windows systems, a little knowledge of FileSystemObject and it's relatives really can save the day.