Solved: vbScript File Owner

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

draceplace

Thread Starter
Joined
Jun 8, 2001
Messages
2,583
How do I get the file owner in a vbscript? In DOS you see the file owner with "dir /Q " . I can't find the VB equivant!!

Wow!, can't believe this question is that hard...I'm looking for a "objFile.Size" like property "objFile.Owner" except that's not it. I've Googled and looked but I'm missing it somehow. surely someone here knows this!!

Thanks for reading my post!!
 

draceplace

Thread Starter
Joined
Jun 8, 2001
Messages
2,583
Public strFileOwner

Sub GetFileOwner(strFile)
Set colItems = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_LogicalFileSecuritySetting='" & strFile & "'}" _
& " WHERE AssocClass=Win32_LogicalFileOwner ResultRole=Owner")
For Each objItem in colItems
' Wscript.Echo objFile.Name & " " & objItem.AccountName
strFileOwner = objItem.AccountName
Next
End Sub
 

draceplace

Thread Starter
Joined
Jun 8, 2001
Messages
2,583
Found out you should check for nulls and empties before you execute. Short cuts and other junk in a directory will cause it to fail....Also so another that seems it would work:

Set objShell = CreateObject ("Shell.Application")
Set objFolder = objShell.Namespace ("C:\aScripts\origionals")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim arrHeaders(13)
For i = 0 to 13
arrHeaders(i) = objFolder.GetDetailsOf (objFolder.Items, i)
Next
For Each strFileName in objFolder.Items
For i = 0 to 13
If i <> 9 then
Wscript.echo arrHeaders(i) _
& ": " & objFolder.GetDetailsOf (strFileName, i)
End If
Next
Wscript.Echo
Next
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top