我想备份 Windows 7 Ent 中映射驱动器的状态。我不想备份驱动器的内容,只是备份路径和分配的字母。
假设我必须重新安装 Windows,我希望能够将所有映射驱动器恢复到相同的驱动器号,因此恢复时//network-path/foldername/仍会被分配F:\。
你有几个/几个选择。这是两个:
如果这些是您自己映射的持久驱动器,那么它们的条目应存储在注册表中的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
Run Code Online (Sandbox Code Playgroud)
输入:
# 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
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
25907 次 |
| 最近记录: |