Sign in to follow this  
Followers 0
doyle.jack

File Owner

5 posts in this topic

Does anyone know of a function that I could use to get the owner of a file? I know that using built in functions I can provide a path/filename and get the different dates, size, attributes, etc. But how could I find out the owner of the file? This is on an NTFS formatted drive.

Share this post


Link to post
Share on other sites



I dont think you can get it w/ any built in feature (I could easily be wrong but I didn't find any reference to it), *but you could do a

DIR /Q 'filename' > temp.txt

and parse the temp file.


Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

Share this post


Link to post
Share on other sites

I dont think you can get it w/ any built in feature (I could easily be wrong but I didn't find any reference to it), *but you could do a

DIR /Q 'filename' > temp.txt

and parse the temp file.

<{POST_SNAPBACK}>

Thanks. I'm not sure of an easy way to parse the file, though.

Share this post


Link to post
Share on other sites

This worked for me:

MsgBox(0,"",GetOwner("C:\AUTOEXEC.BAT"))

Func GetOwner($filename)
    Local $a, $s, $tmpfile = @TEMPDir & '\getowner.txt'
    
    Run(@ComSpec & ' /c DIR /Q "' & $filename & '" > ' & $tmpfile,"",@SW_MINIMIZE)
    $s  = FileReadLine($tmpfile,6)
    FileDelete($tmpfile)
    if $s = "" or @error Then return ""
    $s  = StringStripWS($s,4)
    $a  = StringSplit($s," ")
    if $a[0] >= 5 Then Return $a[5]
    return ""
EndFunc

Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

Share this post


Link to post
Share on other sites

"Works" is interesting...

1) If the file is supplied via UNC \\server\dir\file Dir translates the owner to '...' in a Workgroup setting, unsure about an Active Directory Domain

2) If the file is a mapped network drive the Computer name is set to the local machine not the remote machine. I have files on a server w/ the ownership SERVER1\USER but DIR says it's LOCALCOMPUTER\USER


Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0