vbscript get folder owner

I am trying to find the owner of a folder using File system object in vbscript. I got the folder collection, and need to find the owner for each folder in the collection. How do I go about it?
rupali00Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

merowingerCommented:
Barry62Commented:
You can't use FileSystemObject for that, but you can use a shell:

Set shellApp = CreateObject("Shell.Application")  
        set folderName = sh.Namespace("c:\")  
 
         Set sh = CreateObject("Shell.Application")  
        set fl = sh.Namespace(folder)  
 
        for each f in fl.Items  
            if not f.IsFolder then  
            fl.GetDetailsOf(f,fileown)
            end if
        next
 set fl = nothing  
 set sh = nothing  
Barry62Commented:
sorry:

Set sh = CreateObject("Shell.Application")  
        set fl = sh.Namespace("c:\")  
 
        for each f in fl.Items  
            if not f.IsFolder then  
            fl.GetDetailsOf(f,fileown)
            end if
        next
 set fl = nothing  
 set sh = nothing  
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

Barry62Commented:
OK, I need more coffee!!

Set sh = CreateObject("Shell.Application")  
        set fl = sh.Namespace("c:\")  
 
        for each f in fl.Items  
            if f.IsFolder then  
            fl.GetDetailsOf(f,fileown)
            end if
        next
 set fl = nothing  
 set sh = nothing  
rupali00Author Commented:
Barry,

Thanks for your response.
I tried your solution, it does run without the parentheses at getdetails line, but how do I display the results into a txt file?
Barry62Commented:
I'll write something up real quick
Barry62Commented:
Here you go:

<%
'get folder details
dim folderArray()
dim folderCount
folderCount=0
Set sh = CreateObject("Shell.Application")  
        set fl = sh.Namespace("c:\")  
            for each f in fl.Items
                  redim preserve folderArray(folderCount + 1)
            if f.IsFolder then  
            folderArray(folderCount)=f & " is owned by " & fl.GetDetailsOf(f,8)
                  folderCount=folderCount + 1
            end if
        next
 set fl = nothing  
 set sh = nothing  

'write results to text file
dim fs,fname
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fname=fs.CreateTextFile("c:\folders.txt",true)
for x=0 to folderCount-1
fname.WriteLine(folderArray(x) & vbCrlf)
next
fname.Close
set fname=nothing
set fs=nothing
%>

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Computer101Commented:
Forced accept.

Computer101
EE Admin
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.