Find UNC path of a network drive?

Solution 1:

In Windows, if you have mapped network drives and you don't know the UNC path for them, you can start a command prompt (Start → Run → cmd.exe) and use the net use command to list your mapped drives and their UNC paths:

C:\>net use
New connections will be remembered.

Status       Local     Remote                    Network

-------------------------------------------------------------------------------
OK           Q:        \\server1\foo             Microsoft Windows Network
OK           X:        \\server2\bar             Microsoft Windows Network
The command completed successfully.

Note that this shows the list of mapped and connected network file shares for the user context the command is run under. If you run cmd.exe under your own user account, the results shown are the network file shares for yourself. If you run cmd.exe under another user account, such as the local Administrator, you will instead see the network file shares for that user.

Solution 2:

If you have Microsoft Office:

  1. RIGHT-drag the drive, folder or file from Windows Explorer into the body of a Word document or Outlook email
  2. Select 'Create Hyperlink Here'

The inserted text will be the full UNC of the dragged item.

Solution 3:

This question has been answered already, but since there is a more convenient way to get the UNC path and some more I recommend using Path Copy, which is free and you can practically get any path you want with one click:

https://pathcopycopy.github.io/

Here is a screenshot demonstrating how it works. The latest version has more options and definitely UNC Path too:

enter image description here

Solution 4:

The answer is a simple PowerShell one-liner:

Get-WmiObject Win32_NetworkConnection | ft "RemoteName","LocalName" -A

If you only want to pull the UNC for one particular drive, add a where statement:

Get-WmiObject Win32_NetworkConnection | where -Property 'LocalName' -eq 'Z:'  | ft "RemoteName","LocalName" -A

Solution 5:

wmic path win32_mappedlogicaldisk get deviceid, providername

Result:

DeviceID  ProviderName
I:        \\server1\Temp
J:        \\server2\Corporate
Y:        \\Server3\Dev_Repo
Z:        \\Server3\Repository

As a batch file (src):

@if [%1]==[] goto :Usage
@setlocal enabledelayedexpansion
@set _NetworkPath=
@pushd %1
@for /f "tokens=2" %%i in ('wmic path win32_mappedlogicaldisk get deviceid^, providername ^| findstr /i "%CD:~0,2%"') do @(set _NetworkPath=%%i%CD:~2%)
@echo.%_NetworkPath%
@popd
@goto :EOF
:: ---------------------------------------------------------------------
:Usage
  @echo.
  @echo. Get the full UNC path for the specified mapped drive path
  @echo.
  @echo.  %~n0 [mapped drive path]

Example:

C:\> get-unc-path.bat z:\Tools\admin

\\EnvGeoServer\Repository\Tools\admin

Batch script adapted from https://superuser.com/a/1123556/16966. Please be sure to go vote that one up too if you like this solution.

Update 2021-11-15: bug fix. Previously the batch only reported drive letter UNC root and neglected to also report the folder path.

%CD% is set from %%i through some kind of CMD magic.
%CD:~0,2% and %CD:~2% extract the drive letter and trailing path substrings respectively. e.g. :~2% does '\Tools\admin' from 'Z:\Tools\admin'.