Renaming Mapped Network Drives in Windows

PowerADM.com / PowerShell / Renaming Mapped Network Drives in Windows

When you mount network drives in Windows (manually, via net use, or GPO), File Explorer shows the full UNC path to the mapped network folder as the drive name. In this example, the network shared folder \\DESKTOP-1FOH5A8\Share\Docs\Reports\2022 is mapped as drive Z:\. Displaying the network drive name as a UNC path is inconvenient for many users. In Windows, you can change the name of the mapped network drive through the registry.

mapped network drive name in windows with unc path

The File Explorer in Windows displays the name of the mapped drive based on the information stored in the registry. When you mount a network drive, this information is saved in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2.

In this example, a registry key ##DESKTOP-1FOH5A8#Share#Docs#Reports#2022 was created for the mapped network drive.

To change the display name of a network drive, you need to set the value you want in the _LabelFromReg registry parameter. For example, I want to change the network drive name to MySharedDocs2022.

You can use several scripts to change the network drive name.

Scenario 1 (BAT file):

net use z: /delete
net use z: "\\DESKTOP-1FOH5A8\Share\Docs\Reports\2022" /persistent:no
set reg_path="HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\##DESKTOP-1FOH5A8#Share#Docs#Reports#2022"
reg add %reg_path% /v _LabelFromReg /t REG_SZ /d "MySharedDocs2022" /f

Scenario 2. The second option involves using PowerShell to change the value of the registry parameter:

$FolderPath = "\\DESKTOP-1FOH5A8\Share\Docs\Reports\2022"
$FolderName = 'MySharedDocs2022'
$RegPath = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\##HOMEPC#shared folder#documents#personal'
New-PSDrive -Name Z -Root $FolderPath -PSProvider FileSystem
New-ItemProperty -Path $RegPath -Name _LabelFromReg -Value $FolderName -Force

Scenario 3. Also, you can rename mapped network drive through the Windows Script Server (WSH):

$FolderPath = "\\DESKTOP-1FOH5A8\Share\Docs\Reports\2022"
$FolderName = 'MySharedDocs2022'
New-PSDrive -Name Z -Root $FolderPath -PSProvider FileSystem
$shell = New-Object -ComObject Shell.Application
$shell.NameSpace("Z:").Self.Name = $FolderName

Rename the mapped network drive through the registry with powershell script

In all three cases, the network drive will be displayed with a new name.

Leave a Reply

Your email address will not be published. Required fields are marked *