[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[系统增强] 批处理版系统资料文件转移程序

  1. @echo off
  2. title 命令提示符
  3. if "%1"=="/?" goto help
  4. if "%1"=="/h" goto help
  5. if "%1"=="/H" goto help
  6. if "%1"=="/u" goto original
  7. if "%1"=="/U" goto original
  8. :: for /f "tokens=2*" %%a in ('reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion" /v ProductName 2^>nul^|findstr "Microsoft"') do @set V=%%b
  9. :: if "%V%"=="" echo This program cannot be run in DOS mode.
  10. :: goto end
  11. title 复制并转移系统资料文件夹向导
  12. :input
  13. cls
  14. echo 当前系统资料文件夹名称及位置。如处于关闭状态,请按 U 键恢复一次。
  15. echo.
  16. for /f "tokens=2*" %%a in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v Personal ^|findstr "Personal"') do @set MD=%%b
  17. echo 『我的文档』
  18. echo %MD%
  19. for /f "tokens=3*" %%a in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "My Music" ^|findstr "Music"') do @set MM=%%b
  20. echo 『我的音乐』
  21. echo %MM%
  22. for /f "tokens=3*" %%a in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "My Video" 2^>nul^|findstr "Video"') do @set MV=%%b
  23. echo 『我的视频』
  24. echo %MV%
  25. for /f "tokens=3*" %%a in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "My Pictures" ^|findstr "Pictures"') do @set MP=%%b
  26. echo 『图片收藏夹』
  27. echo %MP%
  28. for /f "tokens=2*" %%a in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v Favorites ^|findstr "Favorites"') do @set F=%%b
  29. echo 『收藏夹』
  30. echo %F%
  31. for /f "tokens=2*" %%a in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v Cache ^|findstr "Temporary"') do @set Ca=%%b
  32. echo 『Cache』
  33. echo %Ca%
  34. for /f "tokens=2*" %%a in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v Cookies ^|findstr "Cookies"') do @set Co=%%b
  35. echo 『Cookies』
  36. echo %Co%
  37. for /f "tokens=2*" %%a in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v History ^|findstr "History"') do @set H=%%b
  38. echo 『History』
  39. echo %H%
  40. for /f "tokens=2 delims={}" %%a in ('REG QUERY HKCU\Identities /v "Default User ID" 2^>nul^|findstr /i "Default"') do @set O=%%a
  41. for /f "tokens=3*" %%a in ('REG QUERY "HKCU\Identities\{%O%}\Software\Microsoft\Outlook Express\5.0" /v "Store Root" 2^>nul^|findstr "Store"') do @set OE=%%b
  42. echo 『Outlook Express』
  43. echo %OE%
  44. for /f "tokens=2*" %%a in ('REG QUERY "HKCU\Environment" /v TEMP ^|findstr "TEMP"') do @set T=%%b
  45. echo 『TEMP』
  46. echo %T%
  47. echo.
  48. set /P OK="请输入一个指令或目标驱动器:[H | Q | U | drive:] "
  49. if "%OK%"=="h" set h=1&&goto help
  50. if "%OK%"=="H" set h=1&&goto help
  51. if "%OK%"=="q" echo.&&echo 正在退出. . .&&call :ProcDelay 200&&goto end
  52. if "%OK%"=="Q" echo.&&echo 正在退出. . .&&call :ProcDelay 200&&goto end
  53. if "%OK%"=="u" goto original
  54. if "%OK%"=="U" goto original
  55. if not exist %OK%\nul goto input
  56. if exist "%MD%\*.*" xcopy "%MD%\*.*" "%OK%\My Documents" /i /q /h /r /y >nul 2>nul
  57. if exist "%Co%\*.*" xcopy "%Co%\*.*" "%OK%\My Documents\Cookies" /s /i /q /h /r /y >nul 2>nul
  58. if exist "%F%\*.*" xcopy "%F%\*.url" "%OK%\My Documents\Favorites" /s /i /q /h /r /y >nul 2>nul
  59. if exist "%H%\*.*" xcopy "%H%\*.*" "%OK%\My Documents\History" /s /i /q /h /r /y >nul 2>nul
  60. if exist "%MM%\*.*" xcopy "%MM%\*.*" "%OK%\My Documents\My Music" /s /i /q /h /r /y >nul 2>nul
  61. if exist "%MP%\*.*" xcopy "%MP%\*.*" "%OK%\My Documents\My Pictures" /s /i /q /h /r /y >nul 2>nul
  62. if exist "%MV%\*.*" xcopy "%MV%\*.*" "%OK%\My Documents\My Videos" /s /i /q /h /r /y >nul 2>nul
  63. if exist "%OE%\*.*" xcopy "%OE%\*.*" "%OK%\My Documents\Outlook Express" /s /i /q /h /r /y >nul 2>nul
  64. if exist "%Ca%\*.*" xcopy "%Ca%\*.*" "%OK%\My Documents\Temporary Internet Files" /s /i /q /h /r /y >nul 2>nul
  65. reg delete "HKCU\Identities\{%O%}" /f>nul
  66. reg add "HKCU\Environment" /v "TEMP" /t REG_EXPAND_SZ /d "%OK%\My Documents\Temp" /f>nul
  67. reg add "HKCU\Environment" /v "TMP" /t REG_EXPAND_SZ /d "%OK%\My Documents\Temp" /f>nul
  68. reg add "HKCU\Identities" /v "Default User ID" /t REG_SZ /d "{88888888-8888-8888-8888-888888888888}" /f>nul
  69. reg add "HKCU\Identities" /v "Last User ID" /t REG_SZ /d "{88888888-8888-8888-8888-888888888888}" /f>nul
  70. reg add "HKCU\Identities\{88888888-8888-8888-8888-888888888888}" /v "User ID" /t REG_SZ /d "{88888888-8888-8888-8888-888888888888}" /f>nul
  71. reg add "HKCU\Identities\{88888888-8888-8888-8888-888888888888}\Software\Microsoft\Outlook Express\5.0" /v "Store Root" /t REG_EXPAND_SZ /d "%OK%\My Documents\Outlook Express\\" /f>nul
  72. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Cache" /t REG_SZ /d "%OK%\My Documents\Temporary Internet Files" /f>nul
  73. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Cookies" /t REG_SZ /d "%OK%\My Documents\Cookies" /f>nul
  74. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Favorites" /t REG_SZ /d "%OK%\My Documents\Favorites" /f>nul
  75. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "History" /t REG_SZ /d "%OK%\My Documents\History" /f>nul
  76. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "My Music" /t REG_SZ /d "%OK%\My Documents\My Music" /f>nul
  77. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "My Pictures" /t REG_SZ /d "%OK%\My Documents\My Pictures" /f>nul
  78. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "My Video" /t REG_SZ /d "%OK%\My Documents\My Videos" /f>nul
  79. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Personal" /t REG_SZ /d "%OK%\My Documents" /f>nul
  80. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Cache" /t REG_EXPAND_SZ /d "%OK%\My Documents\Temporary Internet Files" /f>nul
  81. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Cookies" /t REG_EXPAND_SZ /d "%OK%\My Documents\Cookies" /f>nul
  82. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Favorites" /t REG_EXPAND_SZ /d "%OK%\My Documents\Favorites" /f>nul
  83. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "History" /t REG_EXPAND_SZ /d "%OK%\My Documents\History" /f>nul
  84. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "My Pictures" /t REG_EXPAND_SZ /d "%OK%\My Documents\My Pictures" /f>nul
  85. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Personal" /t REG_EXPAND_SZ /d "%OK%\My Documents" /f>nul
  86. reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Cache\Paths" /v "Directory" /t REG_SZ /d "%OK%\My Documents\Temporary Internet Files\Content.IE5" /f>nul
  87. reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Cache\Paths\path1" /v "CachePath" /t REG_SZ /d "%OK%\My Documents\Temporary Internet Files\Content.IE5\Cache1" /f>nul
  88. reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Cache\Paths\path2" /v "CachePath" /t REG_SZ /d "%OK%\My Documents\Temporary Internet Files\Content.IE5\Cache2" /f>nul
  89. reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Cache\Paths\path3" /v "CachePath" /t REG_SZ /d "%OK%\My Documents\Temporary Internet Files\Content.IE5\Cache3" /f>nul
  90. reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Cache\Paths\path4" /v "CachePath" /t REG_SZ /d "%OK%\My Documents\Temporary Internet Files\Content.IE5\Cache4" /f>nul
  91. echo.
  92. echo 文件夹内容已经复制;注册表信息已经更改,重新启动后生效!
  93. call :ProcDelay 400
  94. goto end
  95. :original
  96. reg add "HKCU\Environment" /v "TEMP" /t REG_EXPAND_SZ /d "%%USERPROFILE%%\Local Settings\Temp" /f>nul
  97. reg add "HKCU\Environment" /v "TMP" /t REG_EXPAND_SZ /d "%%USERPROFILE%%\Local Settings\Temp" /f>nul
  98. reg add "HKCU\Identities" /v "Default User ID" /t REG_SZ /d "{88888888-8888-8888-8888-888888888888}" /f>nul
  99. reg add "HKCU\Identities" /v "Last User ID" /t REG_SZ /d "{88888888-8888-8888-8888-888888888888}" /f>nul
  100. reg add "HKCU\Identities\{88888888-8888-8888-8888-888888888888}" /v "User ID" /t REG_SZ /d "{88888888-8888-8888-8888-888888888888}" /f>nul
  101. reg add "HKCU\Identities\{88888888-8888-8888-8888-888888888888}\Software\Microsoft\Outlook Express\5.0" /v "Store Root" /t REG_EXPAND_SZ /d "%UserProfile%\Local Settings\Application Data\Identities\{88888888-8888-8888-8888-888888888888}\Microsoft\Outlook Express\\" /f>nul
  102. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Cache" /t REG_SZ /d "%USERPROFILE%\Local Settings\Temporary Internet Files" /f>nul
  103. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Cookies" /t REG_SZ /d "%USERPROFILE%\Cookies" /f>nul
  104. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Favorites" /t REG_SZ /d "%USERPROFILE%\Favorites" /f>nul
  105. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "History" /t REG_SZ /d "%USERPROFILE%\Local Settings\History" /f>nul
  106. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "My Music" /t REG_SZ /d "%USERPROFILE%\My Documents\My Music" /f>nul
  107. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "My Pictures" /t REG_SZ /d "%USERPROFILE%\My Documents\My Pictures" /f>nul
  108. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "My Video" /t REG_SZ /d "%USERPROFILE%\My Documents\My Videos" /f>nul
  109. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Personal" /t REG_SZ /d "%USERPROFILE%\My Documents" /f>nul
  110. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Cache" /t REG_EXPAND_SZ /d "%%USERPROFILE%%\Local Settings\Temporary Internet Files" /f>nul
  111. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Cookies" /t REG_EXPAND_SZ /d "%%USERPROFILE%%\Cookies" /f>nul
  112. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Favorites" /t REG_EXPAND_SZ /d "%%USERPROFILE%%\Favorites" /f>nul
  113. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "History" /t REG_EXPAND_SZ /d "%%USERPROFILE%%\Local Settings\History" /f>nul
  114. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "My Pictures" /t REG_EXPAND_SZ /d "%%USERPROFILE%%\My Documents\My Pictures" /f>nul
  115. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Personal" /t REG_EXPAND_SZ /d "%%USERPROFILE%%\My Documents" /f>nul
  116. reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Cache\Paths" /v "Directory" /t REG_SZ /d "%USERPROFILE%\Local Settings\Temporary Internet Files\Content.IE5" /f>nul
  117. reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Cache\Paths\path1" /v "CachePath" /t REG_SZ /d "%USERPROFILE%\Local Settings\Temporary Internet Files\Content.IE5\Cache1" /f>nul
  118. reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Cache\Paths\path2" /v "CachePath" /t REG_SZ /d "%USERPROFILE%\Local Settings\Temporary Internet Files\Content.IE5\Cache2" /f>nul
  119. reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Cache\Paths\path3" /v "CachePath" /t REG_SZ /d "%USERPROFILE%\Local Settings\Temporary Internet Files\Content.IE5\Cache3" /f>nul
  120. reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Cache\Paths\path4" /v "CachePath" /t REG_SZ /d "%USERPROFILE%\Local Settings\Temporary Internet Files\Content.IE5\Cache4" /f>nul
  121. echo.
  122. echo 注册表信息已经恢复,重新启动后生效!
  123. call :ProcDelay 400
  124. goto end
  125. :help
  126. if "%h%"=="1" echo.
  127. echo 复制并转移系统资料文件夹。
  128. echo.
  129. echo DATAMOVE [drive:] [/U] [/Q] [/H]
  130. echo.
  131. echo   drive:  指定您想转移到的目标驱动器
  132. echo   /U      恢复系统默认值
  133. echo   /Q      向导中退出
  134. echo   /H      显示帮助信息
  135. echo.
  136. echo 不加任何参数键入 DATAMOVE,可以启动一个向导。
  137. echo.
  138. echo 目标驱动器将自动添加文件夹路径 My Documents。
  139. echo.
  140. echo 命令行开关 /U 会将更改过的系统注册表信息还原。
  141. echo 它不会还原回您之前已更改系统的任何值,而直接
  142. echo 还原回系统的默认值。
  143. echo.
  144. if "%h%"=="1" pause&&set h=&&goto input
  145. goto end
  146. :ProcDelay number
  147. Setlocal EnableExtensions
  148. for /f "tokens=1-4 delims=:. " %%h in ("%TIME%") do set start_=%%h%%i%%j%%k
  149.      :wait_
  150.      for /f "tokens=1-4 delims=:. " %%h in ("%TIME%") do set now_=%%h%%i%%j%%k
  151.      set /a diff_=%now_%-%start_%
  152. if %diff_% lss %1 goto wait_
  153. Endlocal
  154. :end
  155. set MD=
  156. set MM=
  157. set MV=
  158. set MP=
  159. set F=
  160. set Ca=
  161. set Co=
  162. set H=
  163. set OE=
  164. set T=
  165. set OK=
复制代码
1

评分人数

    • youxi01: 支持原创 建议公布原代码在此PB + 2

个人认为,以作品的形式来体现新手报到(非灌水)的方式值得推崇!!

TOP

现在物价上涨的厉害,就是工资不涨!我这个贴子只值 2 分?!唉...

TOP

正研究批处理,侃侃这个如何做的

TOP

想知道快速转移个人资料的批处理。。。文件头应该要先查找注册表值的。。。

TOP

不错的东西啊!
学习了!

TOP

值得学习,你可以编一个分区和恢复的批处理吗

TOP

现在物价上涨的厉害,就是工资不涨!我这个贴子只值 2 分?!唉...
哈哈哈 顶搂住 经典!

TOP

收藏咧 , , 方便多了

TOP

大哥们,小的出来乍到,怎么没看到哪能发帖子啊?难道发帖还要有等级的?

TOP

回复 10楼 的帖子

Q: 为何无法在某些版块发帖?
A: http://bbs.bathome.net/thread-2128-1-1.html
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

正研究批处理,侃侃这个如何做的

TOP

返回列表