无忧启动论坛

 找回密码
 注册
搜索
系统gho:最纯净好用系统下载站投放广告、加入VIP会员,请联系 微信:wuyouceo
查看: 3179|回复: 4
打印 上一主题 下一主题

请高手帮忙修改批处理.

[复制链接]
跳转到指定楼层
1#
发表于 2011-3-31 18:46:03 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
  1. cls
  2. @echo off
  3. if not "%~n0"=="EncryBat" goto EncryBat_Display
  4. if not "%~n1"=="" if exist "%~f1" copy/b "%~f0"+"%~f1" "%~dp1enc_%~nx1">nul 2>nul&cls&echo.&echo. Enc_%~nx1 is create.&goto :eof
  5. :EncryBat_Help
  6. echo.
  7. echo %~n0 - Cryptographic machine for batch program
  8. echo zxcv@cn-dos, willsort@cn-dos - 2006-8-3 - CMD@WinXP
  9. echo.
  10. echo Useage: %~n0 batch_program_with_extname
  11. echo Reference: http://www.cn-dos.net/forum/viewthread.php?tid=22053  
  12. if /i not [%0]==[EncryBat] pause
  13. goto :eof
  14. :EncryBat_Display
  15. @echo off&setlocal enabledelayedexpansion
  16. color 9f
  17. mode con:cols=55 lines=16
  18. title 个人资料转移批处理版 v1.0  By:MmingHui  
  19. :win
  20. cls
  21. echo.
  22. echo      个人资料转移批处理版 v1.0        By:MmingHui
  23. echo  ╔┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉╗╔┉┉┉┉┉┉┉╗
  24. echo. ┋                              ┋┋              ┋
  25. echo  ┋    本程序预先搜索是否存在    ┋┋  1.资料转移  ┋
  26. echo. ┋    D盘,如果存在D盘则移动    ┋┋              ┋
  27. echo  ┋    我的文档/收藏夹/桌面/     ┋┋  2.恢复转移  ┋
  28. echo. ┋    Cookies到"D:\我的文档"    ┋┋              ┋
  29. echo  ┋                              ┋┋              ┋
  30. echo. ┋    如果搜索没有D盘,则退     ┋┋              ┋
  31. echo. ┋    出程序!                  ┋┋  Z.退出程序  ┋
  32. echo  ┋                              ┋┋              ┋
  33. echo. ╚┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉╝╚┉┉┉┉┉┉┉╝
  34. :cho
  35. set choice=
  36. set /p choice=          请输入对应的按回车:
  37. IF NOT "%Choice%"=="" SET Choice=%Choice:~0,1%
  38. if /i "%choice%"=="1" goto Search
  39. if /i "%choice%"=="2" goto Net
  40. if /i "%choice%"=="Z" goto Exit
  41. echo   输入错误,请重新输入。。。
  42. @ping 127.0.0.1 -n 1 >nul
  43. goto win
  44. pause>nul
  45. :Search
  46. for /f "delims=" %%i in ('fsutil fsinfo drives^|find /v ""') do (
  47. set var=%%i
  48. set drive=!var:~-2!
  49. fsutil fsinfo drivetype !drive!|find /i "固定">nul && echo !drive! >>%Temp%\drive.txt
  50. )
  51. for /f %%a in ('findstr /i "d:" %Temp%\drive.txt') do if /i "%%~a"=="d:" goto yes
  52. goto no
  53. :yes
  54. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Favorites" /t REG_SZ /d "D:\我的文档\My Documents\Favorites" /f >nul
  55. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Personal" /t REG_SZ /d "D:\我的文档\My Documents" /f >nul
  56. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "My Music" /t REG_SZ /d "D:\我的文档\My Documents\My Music" /f >nul
  57. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "My Video" /t REG_SZ /d "D:\我的文档\My Documents\My Video" /f >nul
  58. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "My Pictures" /t REG_SZ /d "D:\我的文档\My Documents\My Pictures" /f >nul
  59. reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DocFolderPaths" /v "Administrator" /t REG_SZ /d "D:\我的文档\My Documents" /f >nul
  60. xcopy "%userprofile%\My Documents\Favorites" "D:\我的文档\My Documents\Favorites" /i /e /h /y /k >nul
  61. xcopy "%userprofile%\Favorites" "D:\我的文档\My Documents\Favorites" /i /e /h /y /k >nul
  62. xcopy "%userprofile%\My Documents" "D:\我的文档\My Documents" /i /e /h /y /k >nul
  63. taskkill /f /im explorer.exe >nul
  64. start explorer.exe >nul
  65. @ping 127.0.0.1 -n 1 >nul
  66. del /f/s/q %Temp%\drive.txt >nul
  67. del /f/s/q/a "%userprofile%\Favorites\*.*" >nul
  68. for /f "delims=" %%a in ('dir /s/b/ad "%userprofile%\Favorites"') do rd /s/q "%%a" >nul 2>nul
  69. del /f/s/q/a "%userprofile%\My Documents\*.*" >nul
  70. for /f "delims=" %%a in ('dir /s/b/ad "%userprofile%\My Documents"') do rd /s/q "%%a" >nul 2>nul
  71. del /f/s/q/a "%userprofile%\Cookies\*.*" >nul
  72. exit
  73. :no
  74. del /f/s/q %Temp%\drive.txt >nul
  75. exit
  76. :net
  77. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Favorites" /t REG_EXPAND_SZ /d "%%USERPROFILE%%\My Documents\Favorites" /f >nul
  78. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Personal" /t REG_EXPAND_SZ /d "%%USERPROFILE%%\My Documents" /f >nul
  79. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "My Music" /t REG_EXPAND_SZ /d "%%USERPROFILE%%\My Documents\My Music" /f >nul
  80. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "My Video" /t REG_EXPAND_SZ /d "%%USERPROFILE%%\My Documents\My Video" /f >nul
  81. 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
  82. reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DocFolderPaths" /v "Administrator" /t REG_SZ /d "%USERPROFILE%\My Documents" /f >nul
  83. xcopy "D:\我的文档\My Documents\Favorites" "%userprofile%\My Documents\Favorites" /i /e /h /y /k >nul
  84. xcopy "D:\我的文档\Favorites" "%userprofile%\My Documents\Favorites" /i /e /h /y /k >nul
  85. xcopy "D:\我的文档\My Documents" "%userprofile%\My Documents" /i /e /h /y /k >nul
  86. taskkill /f /im explorer.exe >nul
  87. start explorer.exe >nul
  88. @ping 127.0.0.1 -n 2 >nul
  89. del /f/s/q/a "D:\我的文档\*.*" >nul
  90. for /f "delims=" %%a in ('dir /s/b/ad "D:\我的文档"') do rd /s/q "%%a" >nul 2>nul
  91. rd /s/q D:\我的文档 >nul
  92. exit
复制代码


批处理如上另外附件也是

我想把上面的功能分开一下。
分成两个批理处。一个是修改我的文档和收藏夹位置的批处理
另一个是还原我的文档和收藏夹位置的批处理

还请高手帮忙修改一下。。并看看这个不是不会检测硬盘。(批处理的作用。检测是否有D盘,如果有D盘修改这些的位置,如果 没有就不修改了)

谢谢了

批处理.rar (1.5 KB, 下载次数: 44)

[ 本帖最后由 94first 于 2011-3-31 18:49 编辑 ]
2#
发表于 2011-3-31 22:04:05 | 只看该作者
转移
@echo off&setlocal enabledelayedexpansion
for /f "delims=\" %%i in ('fsutil fsinfo drives^|find /v ""') do (
set
var=%%i
set drive=!var:~-2!
fsutil fsinfo drivetype !drive!|find /i "固定">nul && echo !drive! >>%Temp%\drive.txt
)
for /f %%a in ('findstr /i "d:" %Temp%\drive.txt') do if /i "%%~a"=="d:" goto yes
goto no
:yes
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Favorites" /t REG_SZ /d "D:\我的文档\My Documents\Favorites" /f >nul
reg
add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Personal" /t REG_SZ /d "D:\我的文档\My Documents" /f >nul
reg
add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "My Music" /t REG_SZ /d "D:\我的文档\My Documents\My Music" /f >nul
reg
add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "My Video" /t REG_SZ /d "D:\我的文档\My Documents\My Video" /f >nul
reg
add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "My Pictures" /t REG_SZ /d "D:\我的文档\My Documents\My Pictures" /f >nul
reg
add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DocFolderPaths" /v "Administrator" /t REG_SZ /d "D:\我的文档\My Documents" /f >nul
xcopy
"%userprofile%\My Documents\Favorites" "D:\我的文档\My Documents\Favorites" /i /e /h /y /k >nul
xcopy
"%userprofile%\Favorites" "D:\我的文档\My Documents\Favorites" /i /e /h /y /k >nul
xcopy
"%userprofile%\My Documents" "D:\我的文档\My Documents" /i /e /h /y /k >nul
taskkill
/f /im explorer.exe >nul
start explorer.exe
>nul
@ping 127.0.0.1 -n 1 >nul
del
/f/s/q %Temp%\drive.txt >nul
del
/f/s/q/a "%userprofile%\Favorites\*.*" >nul
for
/f "delims=" %%a in ('dir /s/b/ad "%userprofile%\Favorites"') do rd /s/q "%%a" >nul 2>nul
del
/f/s/q/a "%userprofile%\My Documents\*.*" >nul
for
/f "delims=" %%a in ('dir /s/b/ad "%userprofile%\My Documents"') do rd /s/q "%%a" >nul 2>nul
del
/f/s/q/a "%userprofile%\Cookies\*.*" >nul
exit
:no
del /f/s/q %Temp%\drive.txt >nul
exit



还原
@echo off
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Favorites" /t REG_EXPAND_SZ /d "%%USERPROFILE%%\My Documents\Favorites" /f >nul
reg
add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Personal" /t REG_EXPAND_SZ /d "%%USERPROFILE%%\My Documents" /f >nul
reg
add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "My Music" /t REG_EXPAND_SZ /d "%%USERPROFILE%%\My Documents\My Music" /f >nul
reg
add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "My Video" /t REG_EXPAND_SZ /d "%%USERPROFILE%%\My Documents\My Video" /f >nul
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
reg
add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DocFolderPaths" /v "Administrator" /t REG_SZ /d "%USERPROFILE%\My Documents" /f >nul
xcopy
"D:\我的文档\My Documents\Favorites" "%userprofile%\My Documents\Favorites" /i /e /h /y /k >nul
xcopy
"D:\我的文档\Favorites" "%userprofile%\My Documents\Favorites" /i /e /h /y /k >nul
xcopy
"D:\我的文档\My Documents" "%userprofile%\My Documents" /i /e /h /y /k >nul
taskkill
/f /im explorer.exe >nul
start explorer.exe
>nul
@ping 127.0.0.1 -n 2 >nul
del
/f/s/q/a "D:\我的文档\*.*" >nul
for
/f "delims=" %%a in ('dir /s/b/ad "D:\我的文档"') do rd /s/q "%%a" >nul 2>nul
rd
/s/q D:\我的文档 >nul
exit

[ 本帖最后由 haiou327 于 2011-3-31 22:22 编辑 ]
回复

使用道具 举报

3#
发表于 2011-3-31 22:28:50 | 只看该作者
for /f %%a in ('findstr /i "d:" %Temp%\drive.txt') do if /i "%%~a"=="d:" goto yes
这句就是检测是否有D盘
回复

使用道具 举报

4#
 楼主| 发表于 2011-4-1 16:45:45 | 只看该作者
谢谢haiou327版主帮忙
回复

使用道具 举报

5#
发表于 2011-6-15 23:41:38 | 只看该作者
高手=、、、、、、、、
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|捐助支持|无忧启动 ( 闽ICP备05002490号-1 )

闽公网安备 35020302032614号

GMT+8, 2024-11-16 22:23

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表