JSI Tip 9187. How can I report the ownership of all the files and folders of a remote share?

Using WhoOwns.bat from How can I get the DIR command to return a file's owner in a batch script, I have scripted WhoOwnsIt.bat to report a local or remote file system objects ownership, and the ownership of all it's sub-folders and files.

The syntax for using WhoOwnsIt.bat is:

WhoOwnsIt FileSystemObject

Where FileSystemObject can be a remote path, like \\ServerName\ShareName, or \\ServerName\ShareName\FolderName, or "C:\Documents and Settings\UserName", etc....

The output is displayed on the console, in CSV (Comma Separated Value) format:


You can easily redirect the output to a file using WhoOwnsIt FileSystemObject>FileName.

WhoOwnsIt.bat contains:

@echo off
if \{%1\}==\{\} @echo Syntax: call WhoOwnsIt Object&goto :EOF
set object=%1
set object="%object:"=%"
call WhoOwns %object% who
@echo %object%,"%who%"
for /f "Tokens=*" %%a in ('dir %object% /b /s /a') do (
 call WhoOwns "%%a" who
 @echo "%%a","!who!"

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.