#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