找回密码
 加入
搜索
查看: 2714|回复: 5

[系统综合] 复制当前用户文件到指定文件夹的问题

  [复制链接]
发表于 2016-2-16 23:27:16 | 显示全部楼层 |阅读模式
小弟菜鸟,刚学几天,写了基础的备份收藏夹的脚本,但是运行总不能备份到指定文件夹,请大神们指点指点

需求:实现拷贝当前用户的收藏夹、文档、桌面备份到指定文件夹

$a=@FavoritesDir
$b=EnvGet("D:\") & "\b\收藏夹"
If FileExists($a) Then
        $c=MsgBox(4 + 32,"提示","文件夹已经找到,是否执行拷贝" _
        & @CRLF & @CRLF & _
        "选择""是""执行拷贝" & @CRLF & _
        "选择""否""放弃拷贝" & @CRLF)
        If $c=6 Then
                DirCopy($a,$b,1)
                ProgressOn("正在复制", "复制进度", "0 percent")
         For $i = 10 to 100 step 10
             sleep(1000)
             ProgressSet( $i, $i & " percent")
                         Next
             ProgressSet(100 , "Done", "Complete")
             sleep(500)
             ProgressOff()
                MsgBox(0 + 48,"提示","收藏夹拷贝完成")
        ElseIf $c=7 Then
                MsgBox(0 + 48,"提示","已经放弃收藏夹拷贝")
        EndIf
        Else
        MsgBox(0 + 48,"提示","文件夹未找到")
EndIf
发表于 2016-2-16 23:55:50 | 显示全部楼层
;~拷贝当前用户的收藏夹、文档、桌面备份到指定文件夹

$a = @FavoritesDir
$b = 'D:\b\收藏夹'
If Not FileExists($a) Then Exit MsgBox(0 + 48, '提示', $a & ' 未找到')
$c = MsgBox(4 + 32, '提示', $a & ' 文件夹已经找到,是否执行拷贝' & @CRLF & @CRLF & _
                '选择"是"执行拷贝' & @CRLF & _
                '选择"否"放弃拷贝' & @CRLF)
If $c = 6 Then
        TrayTip('正在复制', '拷贝当前用户的收藏夹', 10, 1)
        DirCopy($a, $b, 1)
        TrayTip('复制完成', '拷贝当前用户的收藏夹', 10, 1)
        MsgBox(0 + 64, '提示', '收藏夹拷贝完成')
ElseIf $c = 7 Then
        MsgBox(0 + 48, '提示', '已经放弃收藏夹拷贝')
EndIf
发表于 2016-2-17 14:11:43 | 显示全部楼层
Super,12345678901234567890
 楼主| 发表于 2016-2-17 22:24:13 | 显示全部楼层
谢谢大神,有些还不知道咋用呢,我自己F1看帮助吧
发表于 2016-2-22 13:35:12 | 显示全部楼层
送一个批处理给你,虽然不是AU3脚本。
@echo off
title 命令提示符
if "%1"=="/?" goto help
if "%1"=="/h" goto help
if "%1"=="/H" goto help
if "%1"=="/u" goto original
if "%1"=="/U" goto original
title 复制并转移系统资料文件夹向导
:input
cls
echo 当前系统资料文件夹名称及位置。
echo.
for /f "tokens=2*" %%a in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v Personal ^|findstr "Personal"') do @set MD=%%b
echo 『我的文档』
if "%MD%*"=="*" set MD=%USERPROFILE%\My Documents
echo %MD%
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
echo 『我的音乐』
if "%MM%*"=="*" set MM=%USERPROFILE%\My Documents\My Music
echo %MM%
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
echo 『我的视频』
if "%MV%*"=="*" set MV=%USERPROFILE%\My Documents\My Videos
echo %MV%
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
echo 『图片收藏夹』
if "%MP%*"=="*" set MP=%USERPROFILE%\My Documents\My Pictures
echo %MP%
for /f "tokens=2*" %%a in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v Favorites ^|findstr "Favorites"') do @set F=%%b
echo 『收藏夹』
if "%F%*"=="*" set F=%USERPROFILE%\Favorites
echo %F%
for /f "tokens=2*" %%a in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v Cache ^|findstr "Temporary"') do @set Ca=%%b
echo 『Cache』
if "%Ca%*"=="*" set Ca=%USERPROFILE%\Local Settings\Temporary Internet Files
echo %Ca%
for /f "tokens=2*" %%a in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v Cookies ^|findstr "Cookies"') do @set Co=%%b
echo 『Cookies』
if "%Co%*"=="*" set Co=%USERPROFILE%\Cookies
echo %Co%
for /f "tokens=2*" %%a in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v History ^|findstr "History"') do @set H=%%b
echo 『History』
if "%H%*"=="*" set H=%USERPROFILE%\Local Settings\History
echo %H%
for /f "tokens=2 delims={}" %%a in ('REG QUERY HKCU\Identities /v "Default User ID" 2^>nul^|findstr /i "Default"') do @set O=%%a
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
echo 『Outlook Express』
if "%OE%*"=="*" set OE=%USERPROFILE%\Local Settings\Application Data\Identities\{88888888-8888-8888-8888-888888888888}\Microsoft\Outlook Express\\
echo %OE%
for /f "tokens=2*" %%a in ('REG QUERY "HKCU\Environment" /v TEMP ^|findstr "TEMP"') do @set T=%%b
echo 『TEMP』
if "%T%*"=="*" set T=%%USERPROFILE%%\Local Settings\Temp
echo %T%
echo.
set /P OK="请输入一个指令或目标驱动器:[H | Q | U | drive:] "
if "%OK%"=="h" set h=1&&goto help
if "%OK%"=="H" set h=1&&goto help
if "%OK%"=="q" echo.&&echo 正在退出. . .&&call :ProcDelay 200&&goto end
if "%OK%"=="Q" echo.&&echo 正在退出. . .&&call :ProcDelay 200&&goto end
if "%OK%"=="u" goto original
if "%OK%"=="U" goto original
if not exist %OK%\nul goto input
if exist "%MD%\nul" xcopy "%MD%\*.*" "%OK%\My Documents" /i /q /h /r /y >nul 2>nul
if exist "%Co%\nul" xcopy "%Co%\*.*" "%OK%\My Documents\Cookies" /s /i /q /h /r /y >nul 2>nul
if exist "%F%\nul" xcopy "%F%\*.url" "%OK%\My Documents\Favorites" /s /i /q /h /r /y >nul 2>nul
if exist "%H%\nul" xcopy "%H%\*.*" "%OK%\My Documents\History" /s /i /q /h /r /y >nul 2>nul
if exist "%MM%\nul" xcopy "%MM%\*.*" "%OK%\My Documents\My Music" /s /i /q /h /r /y >nul 2>nul
if exist "%MP%\nul" xcopy "%MP%\*.*" "%OK%\My Documents\My Pictures" /s /i /q /h /r /y >nul 2>nul
if exist "%MV%\nul" xcopy "%MV%\*.*" "%OK%\My Documents\My Videos" /s /i /q /h /r /y >nul 2>nul
if exist "%OE%\nul" xcopy "%OE%\*.*" "%OK%\My Documents\Outlook Express" /s /i /q /h /r /y >nul 2>nul
if exist "%Ca%\nul" xcopy "%Ca%\*.*" "%OK%\My Documents\Temporary Internet Files" /s /i /q /h /r /y >nul 2>nul
reg delete "HKCU\Identities\{%O%}" /f>nul
reg add "HKCU\Environment" /v "TEMP" /t REG_EXPAND_SZ /d "%OK%\My Documents\Temp" /f>nul
reg add "HKCU\Environment" /v "TMP" /t REG_EXPAND_SZ /d "%OK%\My Documents\Temp" /f>nul
reg add "HKCU\Identities" /v "Default User ID" /t REG_SZ /d "{88888888-8888-8888-8888-888888888888}" /f>nul
reg add "HKCU\Identities" /v "Last User ID" /t REG_SZ /d "{88888888-8888-8888-8888-888888888888}" /f>nul
reg add "HKCU\Identities\{88888888-8888-8888-8888-888888888888}" /v "User ID" /t REG_SZ /d "{88888888-8888-8888-8888-888888888888}" /f>nul
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
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Cache" /t REG_SZ /d "%OK%\My Documents\Temporary Internet Files" /f>nul
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Cookies" /t REG_SZ /d "%OK%\My Documents\Cookies" /f>nul
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Favorites" /t REG_SZ /d "%OK%\My Documents\Favorites" /f>nul
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "History" /t REG_SZ /d "%OK%\My Documents\History" /f>nul
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "My Music" /t REG_SZ /d "%OK%\My Documents\My Music" /f>nul
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "My Pictures" /t REG_SZ /d "%OK%\My Documents\My Pictures" /f>nul
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "My Video" /t REG_SZ /d "%OK%\My Documents\My Videos" /f>nul
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Personal" /t REG_SZ /d "%OK%\My Documents" /f>nul
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
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Cookies" /t REG_EXPAND_SZ /d "%OK%\My Documents\Cookies" /f>nul
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Favorites" /t REG_EXPAND_SZ /d "%OK%\My Documents\Favorites" /f>nul
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "History" /t REG_EXPAND_SZ /d "%OK%\My Documents\History" /f>nul
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
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Personal" /t REG_EXPAND_SZ /d "%OK%\My Documents" /f>nul
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
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
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
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
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
echo.
echo 文件夹内容已经复制;注册表信息已经更改,重新启动后生效!
call :ProcDelay 400
goto end
:original
reg add "HKCU\Environment" /v "TEMP" /t REG_EXPAND_SZ /d "%%USERPROFILE%%\Local Settings\Temp" /f>nul
reg add "HKCU\Environment" /v "TMP" /t REG_EXPAND_SZ /d "%%USERPROFILE%%\Local Settings\Temp" /f>nul
reg add "HKCU\Identities" /v "Default User ID" /t REG_SZ /d "{88888888-8888-8888-8888-888888888888}" /f>nul
reg add "HKCU\Identities" /v "Last User ID" /t REG_SZ /d "{88888888-8888-8888-8888-888888888888}" /f>nul
reg add "HKCU\Identities\{88888888-8888-8888-8888-888888888888}" /v "User ID" /t REG_SZ /d "{88888888-8888-8888-8888-888888888888}" /f>nul
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
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Cache" /t REG_SZ /d "%USERPROFILE%\Local Settings\Temporary Internet Files" /f>nul
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Cookies" /t REG_SZ /d "%USERPROFILE%\Cookies" /f>nul
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Favorites" /t REG_SZ /d "%USERPROFILE%\Favorites" /f>nul
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "History" /t REG_SZ /d "%USERPROFILE%\Local Settings\History" /f>nul
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "My Music" /t REG_SZ /d "%USERPROFILE%\My Documents\My Music" /f>nul
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "My Pictures" /t REG_SZ /d "%USERPROFILE%\My Documents\My Pictures" /f>nul
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "My Video" /t REG_SZ /d "%USERPROFILE%\My Documents\My Videos" /f>nul
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Personal" /t REG_SZ /d "%USERPROFILE%\My Documents" /f>nul
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
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Cookies" /t REG_EXPAND_SZ /d "%%USERPROFILE%%\Cookies" /f>nul
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Favorites" /t REG_EXPAND_SZ /d "%%USERPROFILE%%\Favorites" /f>nul
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "History" /t REG_EXPAND_SZ /d "%%USERPROFILE%%\Local Settings\History" /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 "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Personal" /t REG_EXPAND_SZ /d "%%USERPROFILE%%\My Documents" /f>nul
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
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
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
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
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
echo.
echo 注册表信息已经恢复,重新启动后生效!
call :ProcDelay 400
goto end
:help
if "%h%"=="1" echo.
echo 复制并转移系统资料文件夹。
echo.
echo DATAMOVE [drive:] [/U] [/Q] [/H]
echo.
echo   drive:  指定您想转移到的目标驱动器
echo   /U      恢复系统默认值
echo   /Q      向导中退出
echo   /H      显示帮助信息
echo.
echo 不加任何参数键入 DATAMOVE,可以启动一个向导。
echo.
echo 目标驱动器将自动添加文件夹路径 My Documents。
echo.
echo 命令行开关 /U 会将更改过的系统注册表信息还原。
echo 它不会还原回您之前已更改系统的任何值,而直接
echo 还原回系统的默认值。
echo.
if "%h%"=="1" pause&&set h=&&goto input
goto end

:ProcDelay number
Setlocal EnableExtensions
for /f "tokens=1-4 delims=:. " %%h in ("%TIME%") do set start_=%%h%%i%%j%%k
     :wait_
     for /f "tokens=1-4 delims=:. " %%h in ("%TIME%") do set now_=%%h%%i%%j%%k
     set /a diff_=%now_%-%start_%
if %diff_% lss %1 goto wait_
Endlocal

:end
set MD=
set MM=
set MV=
set MP=
set F=
set Ca=
set Co=
set H=
set O=
set OE=
set T=
set OK=
发表于 2016-2-23 12:14:56 | 显示全部楼层
afan写的不错,适合学习
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-12-26 12:01 , Processed in 0.079515 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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