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:
"Object","Owner"
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 setlocal ENABLEDELAYEDEXPANSION 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!" ) endlocal
0 comments
Hide comments