(view source code of owner.bat as plain text)
@ECHO OFF
ECHO.
:: Check Windows version
VER | FIND /V "Windows 2000" >NUL
IF NOT ERRORLEVEL 1 GOTO Start
VER | FIND /V "Windows XP" >NUL
IF ERRORLEVEL 1 GOTO WrongVer
:Start
SETLOCAL
:: Check command line parameter
SET OwnedFile=%1
IF NOT DEFINED OwnedFile GOTO Syntax
SET OwnedFile=%OwnedFile:"=%
IF "%OwnedFile%"=="/?" GOTO Syntax
IF NOT EXIST "%OwnedFile%" GOTO Syntax
IF EXIST "%OwnedFile%\" GOTO Syntax
:: Does filespec contain wildcards?
ECHO.%OwnedFile% | FIND "?" >NUL
IF NOT ERRORLEVEL 1 GOTO Multiple
ECHO.%OwnedFile% | FIND "*" >NUL
IF NOT ERRORLEVEL 1 GOTO Multiple
:: Show owner of specified single file; display owner only
FOR /F "skip=5 tokens=4 delims= " %%A IN ('DIR/A-D/Q "%OwnedFile%" ^| FIND /V "(s)"') DO ECHO.%%A
ENDLOCAL
GOTO End
:Multiple
:: Show owner of specified files; display owner and file name
FOR /F "skip=5 tokens=4* delims= " %%A IN ('DIR/A-D/Q "%OwnedFile%" ^| FIND /V "(s)"') DO ECHO.%%A %%B
ENDLOCAL
GOTO End
:WrongVer
ECHO This batch file requires Windows 2000 or a later version
GOTO End
:Syntax
ECHO Owner.bat, Version 1.00 for Windows 2000 / XP
ECHO Show the owner^(s^) of specified file^(s^)
ECHO.
ECHO Usage: %~n0 ^<filespec^>
ECHO.
ECHO ^<filespec^> should NOT be a directory name.
ECHO If ^<filespec^> contains wildcards, both the owners and
ECHO the file names will be displayed ^(tab delimited^)
ECHO.
ECHO Written by Rob van der Woude
ECHO http://www.robvanderwoude.com
:End
page last modified: 2024-04-16; loaded in 0.0047 seconds