• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3716
  • Last Modified:

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?
0
rupali00
Asked:
rupali00
1 Solution
 
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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
 
Computer101Commented:
Forced accept.

Computer101
EE Admin
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now