If you need to determine the 'server name' and 'share name' of a drive letter that was mapped with the net use command, you can call drivemap <DriveLetter> in your batch file. Drivemap.bat returns the server component of the mapped drive in the server environment variable and returns the share name in the the share environment variable. If the drive is not mapped, or you do not provide a valid drive parameter, both environment variables are set to None. Drivemap.bat contains:

@echo off
setlocal
set server=None
set share=None
if \{%1\}<h1><a name="_goto_end_REM_Clean_up_drive_letter_parameter_set_dl_1_set_dl_dl_set_dl_dl_set_dl_dl_set_dl_dl_if_not_exist_dl_goto_end_for_f_Skip_1_Tokens_3_Delims_i_in_net_use_dl_findstr_Remote_name_do_set_server_i_amp_set_share_j_end_endlocal_amp_set_server_server_amp_set_share_share_pre_If_your_CMD_parser_is_pipe_b_font_size_1_font_b_challenged_you_can_use_the_following_script_pre_echo_off_setlocal_set_server_None_set_share_None_if_1_">\{\} goto end
REM Clean up drive letter parameter
set dl=%1
set dl=%dl::=%
set dl=%dl:"=%
set dl=%dl:\=%
set dl=%dl%:
if not exist %dl%\*.* goto end
for /f "Skip=1 Tokens=3* Delims=\ " %%i in ('net use %dl%^|findstr "Remote name"') do set server=%%i&set share=%%j
:end
endlocal&set server=%server%&set share=%share%</a></h1>
If your CMD parser is pipe ( | ) challenged, you can use the following script:
@echo off
setlocal
set server=None
set share=None
if \{%1\}\{\} goto fin
REM Clean up drive letter parameter
set dl=%1
set dl=%dl::=%
set dl=%dl:"=%
set dl=%dl:\=%
set dl=%dl%:
if not exist %dl%\*.* goto fin
for /f "Skip=1 Tokens=1-3* Delims=\ " %%i in ('net use %dl%') do call :parse %%i %%j %%k "%%l"
:fin
endlocal&set server=%server%&set share=%share%
goto end
:parse
if not "%1"=="Remote" goto end
set server=%3
set share=%4
set share=%share:"=%
:end