@ECHO OFF :: Check Windows version and command line arguments IF NOT "%OS%"=="Windows_NT" GOTO Syntax IF "%~1"=="" GOTO Syntax IF NOT "%~2"=="" GOTO Syntax IF NOT EXIST %~d1 GOTO Syntax SETLOCAL ENABLEDELAYEDEXPANSION :: The following code block could be much simpler, if only it would be :: 100 percent certain that the share names wouldn't contain spaces; :: thanks to John Taylor, for reporting the "space bug" in version 1.00 :: Find out if the drive is a mapped network drive, :: and if so translate the drive letter to its UNC path FOR /F "tokens=2*" %%A IN ('NET USE ^| FIND "%~d1"') DO SET UncDrv=%%B :: If the drive is not mapped, try if it is SUBSTituted IF NOT DEFINED UncDrv GOTO :Subst :: Remove the network drive type; you may have to add similar lines to :: remove other drive types, like Netware, but I couldn't test those SET UncDrv=%UncDrv:Microsoft Windows Network=% :: Check for trailing spaces and remove them all :Loop IF NOT "%UncDrv:~-1,1%"==" " ( ECHO "%UncDrv%%~pnx1" GOTO End ) SET UncDrv=%UncDrv:~0,-1% GOTO :Loop :Subst :: Check if the drive is SUBSTituted, and if so find out its true path :: Delims is a greater than, followed by a tab and a space FOR /F "tokens=2* delims=> " %%A IN ('SUBST ^| FIND "%~d1\: =>"') DO ( SET Subst=%%B IF "!Subst:~0,4!"=="UNC\" SET Subst=\!Subst:~3! ECHO.!Subst!%~pnx1 GOTO End ) :: If we arrived here, the drive is neither mapped nor SUBSTituted, :: so we'll have to assume that its path is its true path ECHO.%~f1 :End ENDLOCAL GOTO:EOF :Syntax ECHO. ECHO TrueName, Version 2.00 for Windows NT 4 / 2000 / XP ECHO Displays the true path of a file or directory (like COMMAND.COM's internal ECHO TRUENAME command); handles SUBSTituted drives as well as mapped network drives. ECHO. ECHO Usage: TRUENAME d: ECHO or: TRUENAME d:\path ECHO or: TRUENAME d:\path\filename.ext ECHO. ECHO Enclose path and/or file name in quotes if they contain spaces or ECHO other delimiters ^( + ; , ^) or "forbidden" characters ^( ^& ^| ^< ^> ^). ECHO. ECHO Written by Rob van der Woude ECHO http://www.robvanderwoude.com