备份映射的驱动器路径


0

我想在Windows 7 Ent中备份映射驱动器的状态。我不是要备份驱动器的内容,而是仅备份路径和分配的字母。

假设我必须执行Windows的重新安装,我希望能够将所有映射的驱动器还原到相同的驱动器号,因此还原时//network-path/foldername/仍将分配给该驱动器号F:\


要从cmd行或bat文件执行此操作。
bvaughn

1
净使用> Save_My_Drive_Map.txt
bvaughn

Answers:


2

您有几个选择。这是两个:

如果这些是您自己映射的永久性驱动器,则它们的条目应存储在注册表中的下HKEY_CURRENT_USER\Network

您可以使用Reg Export HKEY_CURRENT_USER\Network c:\temp\drives.reg命令行将密钥导出到文件中,然后reg import在以后再次使用它导入。

有关更多信息,请查看以下现有的SU问题:

Windows在哪里存储网络驱动器映射?

如果驱动器不是持久性驱动器,则可以使用脚本将列表输出到文件,然后使用另一个脚本导入该文件并稍后从中创建驱动器。

使用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 
}
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.