Skip to main content
Fix typo
Source Link

Based on the VBScript approach, you can also perform the same operation using PowerShell.

function Set-DriveName($Drive, $Name){
    (New-Object -ComObject Shell.Application).NameSpace($Drive).Self.Name = $Name
}

And then use the function

Set-DriveName -Drive "Y:" -Name "Drive Name"

Alternatively, if you want to launch this from CMD or from another application, you can use this command:

powershell -c "(New-Object -ComObject Shell.Application).NameSpace('Y:').Self.Name = 'Drive Name'"

PLEASE NOTE: Do not run this command as Administrator if you're trying to rename mapped drives visible only to the local user. You need to run this command in the context of the target user where the target drive appears.

Based on the VBScript approach, you can also perform the same operation using PowerShell.

function Set-DriveName($Drive, $Name){
    (New-Object -ComObject Shell.Application).NameSpace($Drive).Self.Name = $Name
}

And then use the function

Set-DriveName -Drive "Y:" -Name "Drive Name"

Alternatively, if you want to launch this from CMD or from another application, you can use this command:

powershell -c "(New-Object -ComObject Shell.Application).NameSpace('Y:').Self.Name = 'Drive Name'"

Based on the VBScript approach, you can also perform the same operation using PowerShell.

function Set-DriveName($Drive, $Name){
    (New-Object -ComObject Shell.Application).NameSpace($Drive).Self.Name = $Name
}

And then use the function

Set-DriveName -Drive "Y:" -Name "Drive Name"

Alternatively, if you want to launch this from CMD or from another application, you can use this command:

powershell -c "(New-Object -ComObject Shell.Application).NameSpace('Y:').Self.Name = 'Drive Name'"

PLEASE NOTE: Do not run this command as Administrator if you're trying to rename mapped drives visible only to the local user. You need to run this command in the context of the target user where the target drive appears.

Source Link

Based on the VBScript approach, you can also perform the same operation using PowerShell.

function Set-DriveName($Drive, $Name){
    (New-Object -ComObject Shell.Application).NameSpace($Drive).Self.Name = $Name
}

And then use the function

Set-DriveName -Drive "Y:" -Name "Drive Name"

Alternatively, if you want to launch this from CMD or from another application, you can use this command:

powershell -c "(New-Object -ComObject Shell.Application).NameSpace('Y:').Self.Name = 'Drive Name'"