Avatar of gabrielaz
gabrielaz

asked on 

vbscript to list folder names

hello experts,
 looking for a script htat will list all folders in a directory... example
\\server\users.  so i would like all the folders names withing the users directory and list that to
notepad or excel.  thanks in advance.
Windows Server 2003

Avatar of undefined
Last Comment
gabrielaz
ASKER CERTIFIED SOLUTION
Avatar of sirbounty
sirbounty
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of gabrielaz
gabrielaz

ASKER

thanks for the fast response.. it works great. i am new to scripting and i was hoping you explain the way the script works to me like what this stuff does.
Avatar of sirbounty
sirbounty
Flag of United States of America image

First it creates a reference to the files system:
Dim objFSO: Set objFSO = CreateObject("Scripting.FileSystemObject")

Using that , sets another object object to a report file for output info
Dim objOutput: Set objOutput = objFSO.CreateTextFile("C:\Folders.txt")

Establish a variable for the folder
fld="C:\ParentPath\"

run the sub, passing an object reference to that folder
EnumFolders (objFSO.GetFolder(fld))

'Once the sub is finished, close the file and destroy references..
objOutput.Close
Set objOutput=Nothing
Set objFSO = Nothing
wscript.quit

Sub EnumFolders(objFld)
'The next line writes the path of the folder to the output file
    objOutput.WriteLine objFld.Path
The next section loops through all subfolders, restarting the sub for each found
    For Each fld In objFld.SubFolders
        EnumFolders (objFSO.GetFolder(fld))
    Next
End Sub

Glad it worked for you. :^ )
Avatar of gabrielaz
gabrielaz

ASKER

Thank you.
Windows Server 2003
Windows Server 2003

Windows Server 2003 was based on Windows XP and was released in four editions: Web, Standard, Enterprise and Datacenter. It also had derivative versions for clusters, storage and Microsoft’s Small Business Server. Important upgrades included integrating Internet Information Services (IIS), improvements to Active Directory (AD) and Group Policy (GP), and the migration to Automated System Recovery (ASR).

129K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo