Files
Share_Li/Init-DeveloperDrive.ps1

25 lines
887 B
PowerShell
Raw Normal View History

2025-12-20 13:34:05 +00:00
# 2_Move_System_Folders.ps1
$D_Doc = "D:\Document"
2025-12-20 13:25:24 +00:00
2025-12-20 13:34:05 +00:00
# 定义注册表键名与 D 盘新路径的对应关系
$Folders = @{
"Desktop" = "$D_Doc\Desktop"
"Personal" = "$D_Doc\Documents"
"{374DE290-123F-4565-9164-39C4925E467B}" = "$D_Doc\Downloads" # Downloads 键名
"My Pictures" = "$D_Doc\Pictures"
2025-12-20 13:14:39 +00:00
}
2025-12-20 13:34:05 +00:00
$RegistryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders"
2025-12-20 13:14:39 +00:00
2025-12-20 13:34:05 +00:00
foreach ($Key in $Folders.Keys) {
$NewPath = $Folders[$Key]
# 创建 D 盘目录
if (!(Test-Path $NewPath)) { New-Item -Path $NewPath -ItemType Directory -Force }
2025-12-20 13:14:39 +00:00
2025-12-20 13:34:05 +00:00
# 修改注册表
Set-ItemProperty -Path $RegistryPath -Name $Key -Value $NewPath
Write-Host "[成功] $Key 路径已改为 $NewPath" -ForegroundColor Green
}
2025-12-20 13:14:39 +00:00
2025-12-20 13:34:05 +00:00
Write-Host "提示:请重启电脑或重新启动 Windows 资源管理器以应用更改。" -ForegroundColor Yellow