社区应用 最新帖子 精华区 社区服务 会员列表 统计排行
  • 3357阅读
  • 7回复

[转帖]dllcache备份/恢复工具,公开源码

楼层直达
级别: 管理员
发帖
27813
飞翔币
1567
威望
888
飞扬币
129967
信誉值
0

#cs ----------------------------------------------------------------------------
        ***您可以自由使用本代码,只需保留此部分信息***
        AutoIt 版本: 3.2.11.10.1
        源码首发: 自由天空技术论坛 http://www.freeskycd.cn/bbs/
        脚本作者: 自由天空会员 wjq0886
        脚本功能: dllcache备份/恢复工具
#ce ----------------------------------------------------------------------------
#AutoIt3Wrapper_Icon=win2000.ico
#AutoIt3Wrapper_Outfile=dllcache.exe
#AutoIt3Wrapper_Res_Comment=dllcache备份/恢复工具
#AutoIt3Wrapper_Res_Description=dllcache备份/恢复工具
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_Field=作者|自由天空会员 wjq0886
#AutoIt3Wrapper_Res_Field=论坛|http://www.freeskycd.cn/bbs/
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#NoTrayIcon
#include <Misc.au3>

;防止程序二次运行
_Singleton("test")
$g_szVersion = "test"
If WinExists($g_szVersion) Then Exit
AutoItWinSetTitle($g_szVersion)

;gui窗体部分
Local $Form1 = GUICreate("DLLcacheRestore", 400, 155, -1, -1)
FileInstall("logo.bmp", @TempDir & "\")
$Pic1 = GUICtrlCreatePic(@TempDir & "\logo.bmp", 0, 0, 400, 70, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
FileDelete(@TempDir & "\logo.bmp")
$Checkbox1 = GUICtrlCreateCheckbox(" 重启后自动恢复并删除自我", 9, 78, 174, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("备份", 192, 77, 60, 25, 0)
$Button2 = GUICtrlCreateButton("恢复", 259, 77, 60, 25, 0)
$Button3 = GUICtrlCreateButton("退出", 327, 77, 60, 25, 0)
$Label1 = GUICtrlCreateLabel("dllcache备份/恢复工具", 10, 140, 220, 15)
$Label1 = GUICtrlCreateLabel("http://www.freeskycd.cn/bbs/", 215, 135, 180, 15)
GUICtrlSetFont(-1, 10, 400, 4, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlSetCursor(-1, 0)
$Label2 = GUICtrlCreateLabel("正在获取dllcache文件个数...", 8, 105, 180, 15)
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetState($Label2, $GUI_HIDE)
$Label3 = GUICtrlCreateLabel("已做好备份dllcache的准备", 10, 105, 180, 15)
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetState($Label3, $GUI_HIDE)
$Label4 = GUICtrlCreateLabel("已做好恢复dllcache的准备", 10, 105, 180, 15)
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetState($Label4, $GUI_HIDE)
$Label5 = GUICtrlCreateLabel("正在备份dllcache文件...", 10, 105, 180, 15)
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetState($Label5, $GUI_HIDE)
$Label6 = GUICtrlCreateLabel("正在恢复dllcache文件...", 10, 105, 180, 15)
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetState($Label6, $GUI_HIDE)
$Progress1 = GUICtrlCreateProgress(0, 120, 400, 15)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
If @ScriptDir = "C:\WINDOWS\system32\dllcache" Then
        MsgBox(16 + 0, "错误", "本程序不能放在C:\WINDOWS\system32\dllcache,请移至其它位置。")
        Exit
EndIf
If FileExists(@ScriptDir & "\files.ini") Then
        GUICtrlSetState($Checkbox1, $GUI_DISABLE)
        GUICtrlSetState($Label4, $GUI_SHOW)
        GUICtrlSetState($Button1, $GUI_DISABLE)
Else
        GUICtrlSetState($Label3, $GUI_SHOW)
        GUICtrlSetState($Button2, $GUI_DISABLE)
EndIf
GUISetState(@SW_SHOW)

$i = 1
$d = 0
;统计dllcache文件夹包含文件的个数
Func filesnum($path)
        Local $fpath, $fs, $fa
        $fpath = $path & "\*.*"
        Local $f = FileFindFirstFile($fpath)
        While 1
                $fs = FileFindNextFile($f)
                If @error Then
                        FileClose($f)
                        Return
                EndIf
                If $fs = "." Or $fs = ".." Then
                        ContinueLoop
                EndIf
                $fa = FileGetAttrib($path & "\" & $fs)
                If StringInStr($fa, "D") Then
                        filesnum($path & "\" & $fs)
                Else
                        $d = $d + 1
                EndIf
        WEnd
EndFunc   ;==>filesnum

;寻找对应的文件并写入配置文件files.ini
Func FindAll($path)
        Local $fpath, $fs, $fa
        $fpath = $path & "\*.*"
        Local $f = FileFindFirstFile($fpath)
        While 1
                $fs = FileFindNextFile($f)
                If @error Then
                        FileClose($f)
                        Return
                EndIf
                If $fs = "." Or $fs = ".." Then
                        ContinueLoop
                EndIf
                $fa = FileGetAttrib($path & "\" & $fs)
                If StringInStr($fa, "D") And $path & "\" & $fs <> "C:\WINDOWS\system32\dllcache" Then
                        FindAll($path & "\" & $fs)
                Else
                        $str = $path & "\" & $fs
                        $num = StringInStr($str, "\", 0, -1)
                        $filename = StringTrimLeft($str, $num)
                        If FileExists("C:\WINDOWS\system32\dllcache" & "\" & $filename) Then
                                IniWrite(@ScriptDir & "\files.ini", "Backup", $i, $path & "\" & $fs)
                                $arb = FileGetAttrib("C:\WINDOWS\system32\dllcache" & "\" & $filename)
                                If StringInStr($arb, "R") Then
                                        FileSetAttrib("C:\WINDOWS\system32\dllcache" & "\" & $filename, "-R")
                                        FileDelete("C:\WINDOWS\system32\dllcache" & "\" & $filename)
                                Else
                                        FileDelete("C:\WINDOWS\system32\dllcache" & "\" & $filename)
                                EndIf
                                GUICtrlSetData($Progress1, ($i / $d) * 100)
                                $i = $i + 1
                        EndIf
                EndIf
        WEnd
EndFunc   ;==>FindAll

;设置自动恢复运行参数
If $CmdLine[0] = 1 And $CmdLine[1] = "/restore" Then
        If Not FileExists(@ScriptDir & "\files.ini") Then
                If RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Ddllcache") <> "" Then
                        RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Ddllcache")
                EndIf
                MsgBox(16 + 0, "错误", "未找到配置文件files.ini,或者您还没有备份dllcache文件。", 3)
                Exit
        Else
                If RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Ddllcache") <> "" Then
                        RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Ddllcache")
                EndIf
                GUICtrlSetState($Button2, $GUI_DISABLE)
                GUICtrlSetState($Button3, $GUI_DISABLE)
                GUICtrlSetState($Label4, $GUI_HIDE)
                GUICtrlSetState($Label6, $GUI_SHOW)
                $a = 1
                $b = IniRead(@ScriptDir & "\files.ini", "Total", "Count", "")
                While $a <= $b
                        $restore = IniRead(@ScriptDir & "\files.ini", "Backup", $a, "")
                        FileCopy($restore, "C:\WINDOWS\system32\dllcache\")
                        GUICtrlSetData($Progress1, ($a / $b) * 100)
                        $a = $a + 1
                WEnd
                FileDelete(@ScriptDir & "\files.ini")
                Exit
        EndIf
EndIf
 
级别: 管理员
发帖
27813
飞翔币
1567
威望
888
飞扬币
129967
信誉值
0

只看该作者 1 发表于: 2008-12-21
;设置自动恢复并删除自我运行参数
If $CmdLine[0] = 2 And $CmdLine[1] = "/restore" And $CmdLine[2] = "/del" Then
        If Not FileExists(@ScriptDir & "\files.ini") Then
                If RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Ddllcache") <> "" Then
                        RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Ddllcache")
                EndIf
                MsgBox(16 + 0, "错误", "未找到配置文件files.ini,或者您还没有备份dllcache文件。", 3)
                Exit
        Else
                If RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Ddllcache") <> "" Then
                        RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Ddllcache")
                EndIf
                GUICtrlSetState($Button2, $GUI_DISABLE)
                GUICtrlSetState($Button3, $GUI_DISABLE)
                GUICtrlSetState($Label4, $GUI_HIDE)
                GUICtrlSetState($Label6, $GUI_SHOW)
                $a = 1
                $b = IniRead(@ScriptDir & "\files.ini", "Total", "Count", "")
                While $a <= $b
                        $restore = IniRead(@ScriptDir & "\files.ini", "Backup", $a, "")
                        FileCopy($restore, "C:\WINDOWS\system32\dllcache\")
                        GUICtrlSetData($Progress1, ($a / $b) * 100)
                        $a = $a + 1
                WEnd
                FileDelete(@ScriptDir & "\files.ini")
                $bat = FileOpen(@TempDir & "\_del.bat", 1)
                FileWrite($bat, "@echo off" & @CRLF)
                FileWrite($bat, "ping -n 2 127.1 >nul" & @CRLF)
                FileWrite($bat, "del /q " & @ScriptDir & "\" & @ScriptName & @CRLF)
                FileWrite($bat, "del %temp%\_del.bat")
                FileClose($bat)
                Run(@TempDir & "\_del.bat", "", @SW_HIDE)
                Exit
        EndIf
EndIf


While 1
        $nMsg = GUIGetMsg()
        Select
                Case $nMsg = $Label1
                        _IECreate("http://www.freeskycd.cn/bbs/", 0, 1, 0)
                Case $nMsg = $GUI_EVENT_CLOSE
                        DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Form1, "int", 200, "long", 0x00010010)
                        Exit
                Case $nMsg = $Button1 ;备份模块
                        GUICtrlSetState($Checkbox1, $GUI_DISABLE)
                        GUICtrlSetState($Button1, $GUI_DISABLE)
                        GUICtrlSetState($Button3, $GUI_DISABLE)
                        GUICtrlSetState($Label3, $GUI_HIDE)
                        GUICtrlSetState($Label2, $GUI_SHOW)
                        filesnum("C:\WINDOWS\system32\dllcache")
                        GUICtrlSetState($Label2, $GUI_HIDE)
                        GUICtrlSetState($Label5, $GUI_SHOW)
                        If FileExists(@ScriptDir & "\files.ini") Then FileDelete(@ScriptDir & "\files.ini")
                        FindAll("C:")
                        IniWrite(@ScriptDir & "\files.ini", "Total", "Count", $i - 1)
                        If $i - 1 = 0 Then
                                MsgBox(64, "dllcache", "没有可备份文件,或者dllcache文件夹是空的。")
                                FileDelete(@ScriptDir & "\files.ini")
                                DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Form1, "int", 200, "long", 0x00010010)
                                Exit
                        Else
                                If GUICtrlRead($Checkbox1) = 1 Then
                                        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Ddllcache", "REG_SZ", @ScriptDir & "\" & @ScriptName & " /restore /del")
                                EndIf
                                If $d - $i + 1 = 0 Then
                                        MsgBox(64, "dllcache", "dllcache文件夹共有文件: " & $d & " 个。" & @CRLF & "成功备份文件 " & $i - 1 & " 个, " & "dllcache文件全部备份完成。")
                                        DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Form1, "int", 200, "long", 0x00010010)
                                        Exit
                                Else
                                        $ask = MsgBox(4, "dllcache", "dllcache文件夹共有文件: " & $d & " 个。" & @CRLF & "成功备份文件 " & $i - 1 & " 个, " & "未找到对应的文件 " & $d - $i + 1 & " 个。" & @CRLF & @CRLF & "您是否要删除冗沉的dallcache文件?")
                                        If $ask = 6 Then
                                                FileSetAttrib("C:\WINDOWS\system32\dllcache\*.*", "-R")
                                                FileDelete("C:\WINDOWS\system32\dllcache\*.*")
                                                DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Form1, "int", 200, "long", 0x00010010)
                                                Exit
                                        Else
                                                DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Form1, "int", 200, "long", 0x00010010)
                                                Exit
                                        EndIf
                                EndIf
                        EndIf
                Case $nMsg = $Button2 ;恢复模块
                        If RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Ddllcache") <> "" Then
                                RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Ddllcache")
                        EndIf
                        GUICtrlSetState($Button2, $GUI_DISABLE)
                        GUICtrlSetState($Button3, $GUI_DISABLE)
                        GUICtrlSetState($Label4, $GUI_HIDE)
                        GUICtrlSetState($Label6, $GUI_SHOW)
                        $a = 1
                        $b = IniRead(@ScriptDir & "\files.ini", "Total", "Count", "")
                        While $a <= $b
                                $restore = IniRead(@ScriptDir & "\files.ini", "Backup", $a, "")
                                FileCopy($restore, "C:\WINDOWS\system32\dllcache\")
                                GUICtrlSetData($Progress1, ($a / $b) * 100)
                                $a = $a + 1
                        WEnd
                        FileDelete(@ScriptDir & "\files.ini")
                        MsgBox(64, "dllcache", "已经成功恢复dllcache文件" & $b & "个。")
                        DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Form1, "int", 200, "long", 0x00010010)
                        Exit
                Case $nMsg = $Button3
                        DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Form1, "int", 200, "long", 0x00010010)
                        Exit
        EndSelect
WEnd
级别: FLY元勋
发帖
484
飞翔币
608
威望
2156
飞扬币
31374
信誉值
0

只看该作者 2 发表于: 2008-12-21
不错 代码很全
级别: 光盘中级
发帖
68
飞翔币
546
威望
870
飞扬币
373
信誉值
0
只看该作者 3 发表于: 2008-12-28
可惜了  我不会制作软件呀   但还是要支持楼主
级别: 光盘见习
发帖
23
飞翔币
335
威望
8
飞扬币
410
信誉值
0
只看该作者 4 发表于: 2008-12-29
楼主是否可以将那你的原程序上传
级别: 光盘新手
发帖
207
飞翔币
335
威望
29
飞扬币
579
信誉值
0
只看该作者 5 发表于: 2008-12-31
支持!谢谢!
级别: 超级版主
发帖
2197
飞翔币
6783
威望
112
飞扬币
17511
信誉值
0

只看该作者 6 发表于: 2008-12-31
飞扬不知啥时有,
纵放屈伸人莫知,诸靠缠绕我皆依。
级别: 光盘初级
发帖
377
飞翔币
339
威望
154
飞扬币
385
信誉值
0
只看该作者 7 发表于: 2009-01-01
这个要收藏下,这个东西很有用,哎,制作团队越来越少了。