我想备份 Windows 7 Ent 中映射驱动器的状态。我并不是想备份驱动器的内容,而只是备份路径和指定的字母。
假设我必须重新安装 Windows,我希望能够将所有映射驱动器恢复到相同的驱动器号,以便在恢复时//network-path/foldername/
仍能分配F:\
。
答案1
您有几个选择。以下是两个:
如果这些执着的您自己映射的驱动器,则它们的条目应存储在注册表中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
}