::---------------------------------------------------------------------------- :: Version 1.0.3 :: Created by Jacob Kofal :: https://kofal.net ::---------------------------------------------------------------------------- :: ChangeLog ::------------- :: :: |1.0.3 :: |fixed 'from' variable in source computer section :: |1.0.2 :: |Added notice at beginning to share old computer C: drive as MPC :: |1.0.1 :: |Changed UserCheck to work with usernames that have spaces in the name :: |Enabled DelayedExpansion to resolve asking for usernames twice :: |1.0 :: |Initial release, refactored code :: ::---------------------------------------------------------------------------- @echo off ::----------------- :: Variables ::----------------- set version=1.0.3 set share=MPC ::----------------- :: End Variables ::----------------- ::Prep goto :setdate ::endprep ::--------------------- :: Begin Questions ::--------------------- echo. Please share the C: Drive of the old computer as 'MPC' echo. Press any key when done. echo. pause > NUL ::---------------------- :: Username Selection ::---------------------- :start set /p login= Are you logged in as the user?(Y/N): if %login% EQU y ( set fromprofile=%username% cls & goto :choice1 ) :nouser set /p user= What is the username on the old computer?: set /p user1= Is %user% correct?(Y/N): if %user1% EQU y ( set fromprofile=%user% cls & goto :choice1 ) cls & echo. Please try again. & ping -n 2 127.0.0.1> NUL & goto :nouser ::--------------------- :: Network / Local ::--------------------- :choice1 echo. How will you be copying the data? echo. echo. please choose: echo. 1.Over the Network echo. 2.Local Connection set /p copymode= Selection: if %copymode% EQU 1 cls & goto :network if %copymode% EQU 2 cls & goto :local cls & echo. Incorrect selection, please retry. & ping -n 2 127.0.0.1> NUL & goto :choice1 ::--------------------- :: Network Questions ::--------------------- :network echo. Are you running this on source machine or destination machine? echo. 1.Running on destination machine echo. 2.Running on source machine set /p dest= Selection: if %dest% EQU 1 cls & goto :destination if %dest% EQU 2 cls & goto :source cls & echo. Incorrect selection, please retry. & ping -n 2 127.0.0.1> NUL & goto :network ::running on destination computer :destination set to=C:\ ping -n 2 127.0.0.1 > NUL set /p copyfrom= What is the IP Address of the source machine? (e.g.: ^'192.168.1.1^') : set from=\\%copyfrom%\%share%\ if %copyfrom% EQU 127.0.0.1 cls & echo. You cannot choose %copyfrom% & ping -n 2 127.0.0.1> NUL & goto :destination if %copyfrom% EQU localhost cls & echo. You cannot choose %copyfrom% & ping -n 2 127.0.0.1> NUL & goto :destination if exist %from% cls & goto :usercheck cls & goto :destination ) ::running on source computer :source set from=C:\ ping -n 2 127.0.0.1 > NUL cls set /p copyto= What is the IP Address of the destination machine? (e.g.: ^'192.168.1.1^') : set to=\\%copyto%\%share%\ if %copyto% EQU 127.0.0.1 cls & echo. You cannot choose %copyto% & ping -n 2 127.0.0.1> NUL & goto :source if %copyto% EQU localhost cls & echo. You cannot choose %copyto% & ping -n 2 127.0.0.1> NUL & goto :source if exist %to% cls & goto :usercheck cls & echo. Please try again. && ping -n 2 127.0.0.1> NUL & goto :source ) ::--------------------- :: Local Questions ::--------------------- :local echo. Will you be copying from or to an external drive? echo. 1.Copy from C: to external drive echo. 2.Copy from external to C: drive set /p dest= Selection: if %dest% EQU 1 cls & goto :external if %dest% EQU 2 cls & goto :internal cls & echo. Please try again. && ping -n 2 127.0.0.1> NUL & goto :local ::copying to external media :external set from=C:\ set /p copyto= What is the drive letter of the external drive? (e.g.: ^'D^') : if %copyto% EQU C cls & echo. You cannot chose C. & goto :external set to=%copyto%:\ if exist %to% cls mkdir %to%users\%fromprofile%\Documents > NUL 2>&1 goto :usercheck cls & echo. Incorrect drive letter, please retry. & goto :external ::copying from external media :internal set to=C:\ set /p copyfrom= What is the drive letter of the external drive? (e.g.: ^'D^') : set from=%copyfrom%:\ if exist %from% cls & goto :usercheck cls & echo. Incorrect drive letter, please retry. & goto :internal ::----------------- :: User Check ::----------------- ::check to make sure username folders exist on both source and destination devices before copying :usercheck setlocal enabledelayedexpansion set fromcheck=%from%users\%fromprofile% set tocheck=%to%users\%fromprofile% set toprofile=%fromprofile% :usercheck1 if exist "%fromcheck%" ( if exist "%tocheck%" ( cls & goto :copyprep ) else ( echo. Username does not exist on destination device. set /p toprofile= Enter username on destination device: set tocheck=%to%users\!toprofile! cls & goto :usercheck1 ) cls & goto :copyprep ) else ( echo. Username does not exist on source device. set /p fromprofile= Enter username on source device: set fromcheck=%from%users\!fromprofile! cls & goto :usercheck1 ) ::----------------- :: Copy Prep ::----------------- :copyprep setlocal disabledelayedexpansion set from=%from%users\%fromprofile%\ set to=%to%users\%toprofile%\ if exist "%to%Documents\Profile-Migration-%version%_%_isodate%.log" del "%to%Documents\Profile-Migration-%version%_%_isodate%.log" ::----------------- :: Copy Files ::----------------- ::Copy Chrome Bookmarks robocopy "%from%AppData\Local\Google\Chrome\User Data\Default" "%to%AppData\Local\Google\Chrome\User Data\Default" "Bookmarks.*" /R:1 /W:1 /LOG+:%to%Documents\Profile-Migration-%version%_%_isodate%.log /TEE ::Copy Chrome Saved Passwords robocopy "%from%AppData\Local\Google\Chrome\User Data\Default" "%to%AppData\Local\Google\Chrome\User Data\Default" "Login Data" /R:1 /W:1 /LOG+:%to%Documents\Profile-Migration-%version%_%_isodate%.log /TEE ::Copy Outlook Signatures robocopy "%from%AppData\Roaming\Microsoft\Signatures" "%to%AppData\Roaming\Microsoft\Signatures" /E /R:1 /W:1 /LOG+:%to%Documents\Profile-Migration-%version%_%_isodate%.log /TEE ::Copy Sticky Notes from Win10 to Win10 robocopy "%from%AppData\Local\Packages\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe\LocalState" "%to%AppData\Local\Packages\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe\LocalState" plum.sqlite-wal /R:1 /W:1 /LOG+:%to%Documents\Profile-Migration-%version%_%_isodate%.log /TEE ::Copy Sticky Notes from Win7 to Win10 mkdir "%to%AppData\Local\Packages\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe\LocalState\Legacy" robocopy "%from%AppData\Roaming\Microsoft\Sticky Notes" "%to%AppData\Local\Packages\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe\LocalState\Legacy" StickyNotes.snt /R:1 /W:1 /LOG+:%to%Documents\Profile-Migration-%version%_%_isodate%.log /TEE ren "%to%AppData\Local\Packages\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe\LocalState\Legacy\StickyNotes.snt" "%to%AppData\Local\Packages\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe\LocalState\Legacy\ThresholdNotes.snt" ::Copy PSTs in the Outlook AppData folder robocopy "%from%AppData\Roaming\Microsoft\Outlook" "%to%AppData\Roaming\Microsoft\Outlook" *.pst /E /R:1 /W:1 /LOG+:%to%Documents\Profile-Migration-%version%_%_isodate%.log /TEE ::Copy User Folders for %%G in (Desktop,Documents,Downloads,Favorites,Links,Music,Pictures,Videos) do robocopy "%from%%%G" "%to%%%G" /E /R:1 /W:1 /XJD /LOG+:%to%Documents\Profile-Migration-%version%_%_isodate%.log /TEE ::----------------- :: End Script ::----------------- echo. echo.Script Finished. Press Any Key to Continue... pause goto :EOF && exit /b 0 :setdate :: Use WMIC to retrieve date and time FOR /F "skip=1 tokens=1-6" %%G IN ('WMIC Path Win32_LocalTime Get Day^,Month^,Year /Format:table') DO ( IF "%%~I"=="" goto s_done Set _yyyy=%%I Set _mm=00%%H Set _dd=00%%G ) :s_done :: Pad digits with leading zeros Set _mm=%_mm:~-2% Set _dd=%_dd:~-2% :: Display the date in ISO 8601 format: Set _isodate=%_yyyy%-%_mm%-%_dd% goto :start exit