本文介绍了用批处理文件命名驱动器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个命令来重命名一些我在WinXP中映射每个启动的驱动器.我已经完成了映射部分的工作,现在我有兴趣以编程方式使用自定义名称来命名它们,这样我就可以使它们保持直线.

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.

推荐答案

我放弃了DOS,转而学习了PowerShell.最终结果是这样的:

I gave up on DOS and learned PowerShell instead. The end result worked like this:

$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'

这篇关于用批处理文件命名驱动器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 15:43
查看更多