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:
0
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  
0
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  
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

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  
0
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?
0
Barry62Commented:
I'll write something up real quick
0
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
%>
0

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
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.