Change network drive label by command line

30,636

Solution 1

The label command will only work for a physical drive. To rename a mapped network drive, you need to rename it using My Computer on a machine. To automate this for use across many computers, the new label will be saved as a registry key. Look for the following key:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2

Export the "_LabelFromReg" key for the drive in question and import the key on the other machines before your "net use" command.

Solution 2

Another perhaps slightly faster method is using Powershell:

$a = New-Object -ComObject shell.application

$a.NameSpace( "X:\" ).self.name = "YOURLABEL"
Share:
30,636

Related videos on Youtube

Adewale Oluyinka
Author by

Adewale Oluyinka

Updated on September 17, 2022

Comments

  • Adewale Oluyinka
    Adewale Oluyinka over 1 year

    I have just create a new network driver by command line using

    net use
    

    But when I try to change this drive's label by command line using label command, an error occurs:

    C:\>label X: Shared
    Parameters not compatible.
    

    How can I change this by command line?

  • Friedrich Philipp
    Friedrich Philipp over 6 years
    What "_LabelFromReg" key are you talking about? What do I have to write into MountPoints2?
  • Finiox
    Finiox almost 6 years
    Doesn't seem to work? Give me an error that name cannot be found on this object
  • Admin
    Admin almost 2 years
    No errors, but has no effect, the label does not change.