In the actual operation and maintenance, the user configuration and outlook default OST file path are on Disk C, which often leads to insufficient space on Disk C, system crash or other problems that result in the inability to access the desktop, documents, favorites and other data under disk C. It's OK to manually cut configuration and configure OST paths. If there are thousands of computers, people will be stupid,
The key point that new discovery files can display Chinese or icons is how long the cards were here
Be sure to copy the desktop.ini configuration file to the new folder and the new folder is a system attribute. You can use the attrib +s command to add
The rendering of the script is as follows
The code is as follows. Please close all currently opened programs during migration, especially the files under user profile
$olduserfiles=([Environment]::GetFolderPath("Desktop") -split "\\desktop")[0] #Current configuration path #Disk status Get-WmiObject Win32_Volume |Where-Object{$_.DriveLetter} | Sort-Object DriveLetter | Format-Table @{NAME="Disk character";express={$_.DriveLetter}},@{name="Total capacity";express={"{0:N2}" -f ($_.Capacity/1GB)+"G"}},@{name="Remaining capacity";express={"{0:N2}" -f ($_.FreeSpace/1GB)+"G"}} Write-Output "Current profile Lujin: $olduserfiles" do { $volume= Read-Host "Select the drive letter to migrate to" $volume=$volume.Trim().ToUpper()+":" } while( !(Test-Path $volume)) $ostpath=$volume+"\users\mail-ost" #oultook OST default cache strength if (!(Test-Path $ostpath)) {mkdir $ostpath} if ((Test-Path "C:\Program Files (x86)\Microsoft Office\Office14\OUTLOOK.EXE") -or (Test-Path "C:\Program Files\Microsoft Office\Office14\outlook.exe")){ reg add "hkcu\Software\Microsoft\Office\14.0\Outlook" /v ForceOSTPath /t REG_EXPAND_SZ /D $ostpath /F } if ((Test-Path "C:\Program Files (x86)\Microsoft Office\Office15\OUTLOOK.EXE") -or (Test-Path "C:\Program Files\Microsoft Office\Office15\outlook.exe")){ reg add "hkcu\Software\Microsoft\Office\15.0\Outlook" /v ForceOSTPath /t REG_EXPAND_SZ /D $ostpath /F } if ((Test-Path "C:\Program Files (x86)\Microsoft Office\Office16\OUTLOOK.EXE") -or (Test-Path "C:\Program Files\Microsoft Office\Office16\outlook.exe")){ reg add "hkcu\Software\Microsoft\Office\16.0\Outlook" /v ForceOSTPath /t REG_EXPAND_SZ /D $ostpath /F } $newuserfiles=$volume+$env:HOMEPATH if (!(Test-Path $newuserfiles)) {mkdir $newuserfiles} #Copy data to, new path xcopy.exe $olduserfiles $newuserfiles /y /s /e #Copy the configuration desktop.ini to the corresponding new path move-Item "$olduserfiles\desktop\desktop.ini" "$newuserfiles\desktop" -Force move-Item "$olduserfiles\Music\desktop.ini" "$newuserfiles\Music" -Force move-Item "$olduserfiles\Downloads\desktop.ini" "$newuserfiles\Downloads" -Force move-Item "$olduserfiles\Documents\desktop.ini" "$newuserfiles\Documents" -Force move-Item "$olduserfiles\Pictures\desktop.ini" "$newuserfiles\Pictures" -Force move-Item "$olduserfiles\Searches\desktop.ini" "$newuserfiles\Searches" -Force move-Item "$olduserfiles\Favorites\desktop.ini" "$newuserfiles\Favorites" -Force move-Item "$olduserfiles\Videos\desktop.ini" "$newuserfiles\Videos" -Force move-Item "$olduserfiles\Links\desktop.ini" "$newuserfiles\Links" -Force move-Item "$olduserfiles\Contacts\desktop.ini" "$newuserfiles\Contacts" -Force move-Item "$olduserfiles\Saved Games\desktop.ini" "$newuserfiles\Saved Games" -Force move-Item "$olduserfiles\3D Objects\desktop.ini" "$newuserfiles\3D Objects" -ErrorAction SilentlyContinue -Force #Traverse the folder of xinlujin and change it to system file Get-ChildItem -Path $newuserfiles | Where-Object {$_.Mode -like "d*"} |ForEach-Object{attrib +s $_.fullname} #Delete old files Get-ChildItem -Path $olduserfiles | Where-Object {$_.Mode -like "d*"} |ForEach-Object{cmd /c rd $_.fullname /q /s} Get-ChildItem -Path $olduserfiles | Where-Object {$_.Mode -like "d*"} |ForEach-Object{cmd /c rd $_.fullname /q /s} #Modify registry $RegPath = "Hkcu:\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" Set-ItemProperty -PATH $RegPath -Name "{374DE290-123F-4565-9164-39C4925E467B}" -Value $newuserfiles"\Downloads" Set-ItemProperty -PATH $RegPath -Name "{4C5C32FF-BB9D-43B0-B5B4-2D72E54EAAA4}" -Value $newuserfiles"\Saved Games" Set-ItemProperty -PATH $RegPath -Name "{56784854-C6CB-462B-8169-88E350ACB882}" -Value $newuserfiles"\Contacts" Set-ItemProperty -PATH $RegPath -Name "{7D1D3A04-DEBB-4115-95CF-2F29DA2920DA}" -Value $newuserfiles"\Searches" Set-ItemProperty -PATH $RegPath -Name "{BFB9D5E0-C6A9-404C-B2B2-AE6DB6AF4968}" -Value $newuserfiles"\Links" Set-ItemProperty -PATH $RegPath -Name "Desktop" -Value $newuserfiles"\Desktop" Set-ItemProperty -PATH $RegPath -Name "Favorites" -Value $newuserfiles"\Favorites" Set-ItemProperty -PATH $RegPath -Name "My Music" -Value $newuserfiles"\Music" Set-ItemProperty -PATH $RegPath -Name "My Pictures" -Value $newuserfiles"\Pictures" Set-ItemProperty -PATH $RegPath -Name "My Videos" -Value $newuserfiles"\Videos" Set-ItemProperty -PATH $RegPath -Name "Personal" -Value $newuserfiles"\Documents" $RegPath = "Hkcu:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" Set-ItemProperty -PATH $RegPath -Name "{0DDD015D-B06C-45D5-8C4C-F59713854639}" -Value $newuserfiles"\Pictures" Set-ItemProperty -PATH $RegPath -Name "{35286A68-3C57-41A1-BBB1-0EAE73D76C95}" -Value $newuserfiles"\Videos" Set-ItemProperty -PATH $RegPath -Name "{374DE290-123F-4565-9164-39C4925E467B}" -Value $newuserfiles"\Downloads" Set-ItemProperty -PATH $RegPath -Name "{4C5C32FF-BB9D-43B0-B5B4-2D72E54EAAA4}" -Value $newuserfiles"\Saved Games" Set-ItemProperty -PATH $RegPath -Name "{56784854-C6CB-462B-8169-88E350ACB882}" -Value $newuserfiles"\Contacts" Set-ItemProperty -PATH $RegPath -Name "{754AC886-DF64-4CBA-86B5-F7FBF4FBCEF5}" -Value $newuserfiles"\Desktop" Set-ItemProperty -PATH $RegPath -Name "{7D1D3A04-DEBB-4115-95CF-2F29DA2920DA}" -Value $newuserfiles"\Searches" Set-ItemProperty -PATH $RegPath -Name "{7D83EE9B-2244-4E70-B1F5-5393042AF1E4}" -Value $newuserfiles"\Downloads" Set-ItemProperty -PATH $RegPath -Name "{A0C69A99-21C8-4671-8703-7934162FCF1D}" -Value $newuserfiles"\Music" Set-ItemProperty -PATH $RegPath -Name "{BFB9D5E0-C6A9-404C-B2B2-AE6DB6AF4968}" -Value $newuserfiles"\Links" Set-ItemProperty -PATH $RegPath -Name "{F42EE2D3-909F-4907-8871-4C22FC0BF756}" -Value $newuserfiles"\Documents" Set-ItemProperty -PATH $RegPath -Name "Desktop" -Value $newuserfiles"\Desktop" Set-ItemProperty -PATH $RegPath -Name "Favorites" -Value $newuserfiles"\Favorites" Set-ItemProperty -PATH $RegPath -Name "My Music" -Value $newuserfiles"\Music" Set-ItemProperty -PATH $RegPath -Name "My Pictures" -Value $newuserfiles"\Pictures" Set-ItemProperty -PATH $RegPath -Name "My Videos" -Value $newuserfiles"\Videos" Set-ItemProperty -PATH $RegPath -Name "Personal" -Value $newuserfiles"\Documents" #Refresh Stop-Process -Name Explorer -f -ErrorAction SilentlyContinue | Out-Null