| |
| @echo off |
| rem 本脚本已通过Windows XP,Windows 7(x64),Windows 7(x86)运行环境测试,Vista原则上和Windows 7相同 |
| rem 本脚本能实现在同PC上安装在多个系统的情况下同步用户资料,及单系统转移用户资料,让你在重新安装系统不再担心用户资料丢失、保存的游戏及应用程序设置丢失! |
| rem 目前只提供常规转移代码,后续将优化完整转移包含AppData文件夹 |
| rem 本脚本出处bbs.bathome.net By:fastslz,转载请注明! |
| ver|find "5.1"&&set "SysID=WinXP" |
| ver|find "6.0"&&set "SysID=WinV" |
| ver|find "6.1"&&set "SysID=Win7" |
| if not exist "%UserName%\nul" md "%UserName%" 2>nul |
| set "dDir=%~dp0"&set "uDir=%~dp0%UserName%" |
| if %SysID%#==WinXP# call :WinXP |
| if %SysID%#==Win7# call :Win7 |
| if %SysID%#==WinV# call :Win7 |
| echo.&echo 用户资料转移已完成,强烈推荐请立即注销并重新登录您的计算机。 |
| ping -n 10 127.0.1>nul 2>nul |
| if exist "日志.log" start "" "日志.log"&exit |
| :WinXP |
| echo 设置用户资料转移到 %uDir% |
| call :mk5 "Documents","Favorites","Desktop","Videos","Pictures","Music" |
| goto:eof |
| :Win7 |
| echo 设置用户资料转移到 %uDir% |
| if exist "日志.log" >日志.log echo 下列的用户资料转移到 %uDir% |
| net stop WMPNetworkSvc |
| call :mk6 "Documents","Favorites","Desktop","Contacts","Saved Games","Links","Videos","Pictures","Music","Downloads","Searches" |
| net start WMPNetworkSvc |
| goto:eof |
| :mk5 |
| if "%~1"=="" goto:eof |
| setlocal enabledelayedexpansion |
| set "key=%~1" |
| if /i "!key!"=="Videos" set "key=My Video" |
| if /i "!key!"=="Music" set "key=My Music" |
| if /i "!key!"=="Pictures" set "key=My Pictures" |
| if /i "!key!"=="Documents" set "key=Personal" |
| if not exist "!uDir!\%~1\nul" md "!uDir!\%~1\" 2>nul |
| reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /f /v "!key!" /t REG_SZ /d "!uDir!\%~1" >nul 2>nul |
| reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /f /v "!key!" /t REG_EXPAND_SZ /d "!uDir!\%~1" >nul 2>nul |
| if /i "!key!"=="Desktop" ( |
| if not exist "!uDir!\桌面\nul" md "!uDir!\桌面\" 2>nul |
| reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /f /v "!key!" /t REG_SZ /d "!uDir!\桌面" >nul 2>nul |
| reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /f /v "!key!" /t REG_EXPAND_SZ /d "!uDir!\桌面" >nul 2>nul |
| ) |
| shift |
| endlocal |
| goto:mk5 |
| :mk6 |
| if "%~1"=="" goto:eof |
| setlocal enabledelayedexpansion |
| if exist "%HOMEDRIVE%%HOMEPATH%\%~1\*" ( |
| robocopy /e /copyall /xj /r:0 /w:0 /log+:日志.log /np /ndl /ns /fp /njh /njs "%HOMEDRIVE%%HOMEPATH%\%~1" "!uDir!\%~1" 2>nul |
| set "error=%errorlevel%" |
| if !error! equ 16 echo 请以管理员身份运行! |
| if !error! neq 16 rd /s/q "%HOMEDRIVE%%HOMEPATH%\%~1" 2>nul |
| ) |
| set "key=%~1" |
| if /i "!key!"=="Downloads" set "key={374DE290-123F-4565-9164-39C4925E467B}" |
| if /i "!key!"=="Contacts" set "key={56784854-C6CB-462B-8169-88E350ACB882}" |
| if /i "!key!"=="Links" set "key={BFB9D5E0-C6A9-404C-B2B2-AE6DB6AF4968}" |
| if /i "!key!"=="Searches" set "key={7D1D3A04-DEBB-4115-95CF-2F29DA2920DA}" |
| if /i "!key!"=="Saved Games" set "key={4C5C32FF-BB9D-43B0-B5B4-2D72E54EAAA4}" |
| if /i "!key!"=="Videos" set "key=My Video" |
| if /i "!key!"=="Music" set "key=My Music" |
| if /i "!key!"=="Pictures" set "key=My Pictures" |
| if /i "!key!"=="Documents" set "key=Personal" |
| reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /f /v "!key!" /t REG_SZ /d "!uDir!\%~1" >nul 2>nul |
| reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /f /v "!key!" /t REG_EXPAND_SZ /d "!uDir!\%~1" >nul 2>nul |
| shift |
| endlocal |
| goto:mk6COPY |