Using RMTShare.exe, I have scripted MapPath.bat to return a server's drive and folder path using a client's mapped drive letter.

The syntax for using MapPath.bat is:

\[CALL\] MapPath Drive: answer


Drive: is the mapped drive letter and colon.

answer is a call directed environment variable that will contain the the server's Drive and folder path, or NONE if Drive: cannot be located. If the folder path contains spaces, the answer string will be quoted.


<font size="1"><b>Mapped   Share                     'server' drive and folder path                          Answer</b>

    X:     \\Computer1\Share1      c:\test                                                 c:\test
    Y:     \\Computer2\Share2      C:\Documents and Settings\Jerry\My Documents\My Stuff   "C:\Documents and Settings\Jerry\My Documents\My Stuff"
    Z:     \\Compurer0\NotFound    . . . . .                                               <b>NONE</b></font>
MapPath.bat contains:
@echo off
if \{%2\}==\{\} goto err
set work=%1
set work=%work:"=%
set DRV=%work:~0,2%
if "%DRV:~1,1%" NEQ ":" goto err
set share=NONE
set ans=N
for /f "tokens=1,2*" %%a in ('net use %DRV%^|find "Remote"^|find "name"') do (
 set share=%%c
if "%share%" EQU "NONE" goto finish
for /f "Tokens=1*" %%a in ('rmtshare %share%^|Findstr /b /c:"Path "') do (
 set ans=%%b
set work=%ans: =%
if "%work%" EQU "%ans%" goto finish
set ans="%ans%"
endlocal&set %2=%ans%
goto :EOF
@echo Syntax:  MapPath Drive: answer