Answers:
您有几个选择。这是两个:
如果这些是您自己映射的永久性驱动器,则它们的条目应存储在注册表中的下HKEY_CURRENT_USER\Network。
您可以使用Reg Export HKEY_CURRENT_USER\Network c:\temp\drives.reg命令行将密钥导出到文件中,然后reg import在以后再次使用它导入。
有关更多信息,请查看以下现有的SU问题:
如果驱动器不是持久性驱动器,则可以使用脚本将列表输出到文件,然后使用另一个脚本导入该文件并稍后从中创建驱动器。
使用PowerShell做到这一点并不难;您可以使用以下内容...
出口:
# Define array to hold identified mapped drives.
$mappedDrives = @()
# Get a list of the drives on the system, including only FileSystem type drives.
$drives = Get-PSDrive -PSProvider FileSystem
# Iterate the drive list
foreach ($drive in $drives) {
# If the current drive has a DisplayRoot property, then it's a mapped drive.
if ($drive.DisplayRoot) {
# Exctract the drive's Name (the letter) and its DisplayRoot (the UNC path), and add then to the array.
$mappedDrives += Select-Object Name,DisplayRoot -InputObject $drive
}
}
# Take array of mapped drives and export it to a CSV file.
$mappedDrives | Export-Csv mappedDrives.csv
输入:
# Import drive list.
$mappedDrives = Import-Csv mappedDrives.csv
# Iterate over the drives in the list.
foreach ($drive in $mappedDrives) {
# Create a new mapped drive for this entry.
New-PSDrive -Name $drive.Name -PSProvider "FileSystem" -Root $drive.DisplayRoot -Persist -ErrorAction Continue
}