我正在寻找一个命令来重命名我在WinXP中映射每个启动的几个驱动器。我已经有了映射部分,我现在有兴趣用自定义名称以编程方式命名它们,所以我可以保持它们。
答案 0 :(得分:5)
我放弃了DOS并学习了PowerShell。最终结果如下:
$Net = New-Object -ComObject WScript.Network
$Rename = New-Object -ComObject Shell.Application
#### # Map the local drives
Subst Q: 'C:\File Path\Uno'
Subst U: 'C:\File Path\Dos'
#### # Map the network drives
$Net.MapNetworkDrive("X:", '\\Server\File Path\Uno')
$Net.MapNetworkDrive("Y:", '\\Different Server\File Path\Dos')
#### # Rename everything
$rename.NameSpace("Q:\").Self.Name = 'Network -> FOO'
$rename.NameSpace("U:\").Self.Name = 'Network -> BAR'
$rename.NameSpace("X:\").Self.Name = 'Local -> FOO'
$rename.NameSpace("Y:\").Self.Name = 'Local -> BAR'
答案 1 :(得分:2)
在命令提示符下输入:
LABEL x: yourlabel
x:
是您的驱动器号,yourlabel
是您希望拥有的名称。
来自LABEL /?
:
Creates, changes, or deletes the volume label of a disk.
LABEL [drive:][label]
LABEL [/MP] [volume] [label]
drive: Specifies the drive letter of a drive.
label Specifies the label of the volume.
/MP Specifies that the volume should be treated as a
mount point or volume name.
volume Specifies the drive letter (followed by a colon),
mount point, or volume name. If volume name is specified,
the /MP flag is unnecessary.
编辑: 正如@mark所指出的,这不适用于映射驱动器。这似乎是一个常见的问题,可能有一种方法可以通过registry实现这一目标,或者通过使用较小的vbs script来实现这一目标。
答案 2 :(得分:0)
REM ad label to any drive
set SETl=TEMP
set SETD=B
echo strComputer = "." > LTEMP.vbs && echo Set objWMIService = GetObject("winmgmts:" _ >> LTEMP.vbs && echo + "{impersonationLevel=impersonate}!\\" + strComputer + "\root\cimv2") >> LTEMP.vbs && echo. >> LTEMP.vbs && echo Set colDrives = objWMIService.ExecQuery _ >> LTEMP.vbs && echo ("Select * from Win32_LogicalDisk where DeviceID = '%SETD%:'") >> LTEMP.vbs && echo. >> LTEMP.vbs && echo For Each objDrive in colDrives >> LTEMP.vbs && echo objDrive.VolumeName = "%SETl%" >> LTEMP.vbs && echo objDrive.Put_ >> LTEMP.vbs && echo Next >> LTEMP.vbs && cscript LTEMP.vbs && del LTEMP.vbs