I am looking for a command to rename a few drives that I map every start-up in WinXP. I've got the mapping part down, I'm now interested in naming them programmatically with custom names, so I can keep them straight.
问问题
32047 次
3 回答
6
我放弃了 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'
于 2012-10-11T16:42:17.760 回答
3
在命令提示符下,输入:
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 所指出的,这不适用于映射驱动器。这似乎是一个常见问题,并且可能有一种方法可以通过注册表来实现,或者使用一个小的vbs 脚本更容易一些。
于 2012-09-26T19:47:55.970 回答
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
于 2020-11-27T20:10:33.493 回答