找回密码
 加入
搜索
查看: 2864|回复: 2

一键备份还原

[复制链接]
发表于 2008-6-23 11:08:52 | 显示全部楼层 |阅读模式
代码:

--------------------------------------------------------------------------------


#NoTrayIcon 
#Region ;**** 参数创建于 AutoIt3Wrapper_GUI **** 
#AutoIt3Wrapper_icon=biosclub.ico 
#AutoIt3Wrapper_outfile=onekey.exe 
#AutoIt3Wrapper_UseUpx=n 
#EndRegion ;**** 参数创建于 AutoIt3Wrapper_GUI **** 
#include <GUIConstants.au3> 
#include <process.au3> 
#include <Constants.au3> 
#include <file.au3> 
#include <array.au3> 
#include <GUIStatusBar.au3> 
#include <GuiTab.au3> 

Dim $Dll 
;判断程序是否重复运行 
$g_szVersion = "ZeroTOOLSv1.0" 
If WinExists($g_szVersion) Then Exit 
AutoItWinSetTitle($g_szVersion) 
;建立工具箱目录 
$finddir=FileFindFirstFile (StringLeft(@WindowsDir,2)&"\ZeroDOS") 
if $finddir=-1 then 
DirCreate (StringLeft(@WindowsDir,2)&"\ZeroDOS") 
EndIf 

FileInstall("D:\au3脚本\onekey v1.0\biosclub.ico",@SystemDir&"\",1) 
;FileInstall("D:\au3脚本\onekey v1.0\biosclub.ico",@WindowsDir&"\",1) 
;FileInstall("D:\au3脚本\onekey v1.0\Stylish.skf",@SystemDir&"\",1) 
;FileInstall("D:\au3脚本\onekey v1.0\XP-style.skf",@SystemDir&"\",1) 
;FileInstall("D:\au3脚本\onekey v1.0\logo.jpg",@SystemDir&"\",1) 
;FileInstall("D:\au3脚本\onekey v1.0\SkinCrafterDll.dll",@SystemDir&"\",1) 
#Region ### START Koda GUI section ### Form=D:\au3脚本\收藏夹程序\Form1.kxf 
;获取硬盘分区参数开始 
;************************************************************************** 
;查看并生 
Dim $partfile,$hdinfo,$hdinfolast,$str,$partno,$CountLines,$strlast,$partnolast,$p 
;获取硬盘分区参数结束 

$var = DriveGetDrive("FIXED") 
If Not @error Then 
; $i = $var[0] 
For $p = 1 To $var[0] 
;$varhd = GUICtrlSetData($AcceptList1, StringUpper($var 

)) 
$lasthd = StringUpper($var[0]) 
$lastdrv = StringUpper($var[$lasthd]) 
Next 
EndIf 

$windir=StringLeft(@WindowsDir,2) 
$windirs=(Round(DriveSpaceTotal($windir)) - Round(DriveSpaceFree($windir))) & "M" 
$windirp=DriveGetFileSystem($windir) 
$winsys=@OSVersion 
$getlist=StringLeft(@WindowsDir,1) 
Select   
Case $winsys="WIN_2003" 
$winos="Windows 2003" 
Case $winsys="WIN_XP" 
$winos="Windows XP" 
case $winsys="WIN_2000" 
$winos="Windows 2000" 
case $winsys="WIN_NT4" 
$winos="Windows NT4" 
EndSelect   
#Region ### START Koda GUI section ### Form=D:\au3脚本\onekey v1.0\Form1.kxf 
$about = GUICreate(" ZeroOneKey GHOST11   V1.0", 324, 184, -1, -1) 
GUISetIcon(@SystemDir &"\biosclub.ico") 
_SkinGUI(@SystemDir &"\SkinCrafterDll.dll", @SystemDir &"\XP-style.skf", $about)   皮肤功能实现 
$aboutGroup1 = GUICtrlCreateGroup("版本信息:", 8, 2, 307, 78) 
$aboutLabel1 = GUICtrlCreateLabel("程序中文名:零点一键备份还原 V1.0版", 16, 18, 250, 17, $WS_GROUP) 
$aboutLabel2 = GUICtrlCreateLabel("程序英文名:ZeroOneKey V1.0", 16, 38, 250, 17, $WS_GROUP) 
$aboutLabel3 = GUICtrlCreateLabel("程序内核名:GHOST 11.0.1.1533", 16, 58, 250, 17, $WS_GROUP) 
GUICtrlCreateGroup("", -99, -99, 1, 1) 
$aboutGroup2 = GUICtrlCreateGroup("请选择:", 8, 80, 307, 70) 
$aboutLabel4 = GUICtrlCreateLabel("硬盘第一分区为:"&$hdinfofist, 16, 95, 200, 17, $WS_GROUP) 
$aboutLabel5 = GUICtrlCreateLabel("系统所在分区为:"&$windir, 160, 95, 140, 17, $WS_GROUP) 
$bakup = GUICtrlCreateButton("备份(&B)", 55, 115, 75, 25) 
$restore = GUICtrlCreateButton("还原(&R)", 140, 115, 75, 25) 
$btcancel = GUICtrlCreateButton("取消(&C)", 225, 115, 75, 25) 
GUICtrlCreateGroup("", -99, -99, 1, 1) 
$aboutLabel7 = GUICtrlCreateLabel("程序:http://www.biosclub.com   QQ:78357343", 16, 160, 270, 17, $WS_GROUP) 
;GUICtrlSetState(-1, $GUI_HIDE) 


GUISetState(@SW_SHOW) 
#EndRegion ### END Koda GUI section ### 
While 1 
$nMsg = GUIGetMsg() 
Switch $nMsg 
Case $GUI_EVENT_CLOSE 
Exit 
case $bakup 
GUIDelete($about) 
bakup() 
case $restore 
GUIDelete($about) 
restore() 
case $btcancel 
Exit 
EndSwitch 
WEnd 


func bakup() 

#Region ### START Koda GUI section ### Form=D:\au3脚本\onekey v1.0\Form1.kxf 
$Form1 = GUICreate("ZeroOneKey GHOST11   V1.0", 355, 190, -1, -1,BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX)) 
GUISetIcon(@SystemDir &"\biosclub.ico") 
_SkinGUI(@SystemDir &"\SkinCrafterDll.dll", @SystemDir &"\Stylish.skf", $Form1)   皮肤功能实现 
$Group1 = GUICtrlCreateGroup("系统信息:", 8, 0, 340, 57) 
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") 
$Label1 = GUICtrlCreateLabel("操作系统:"&$winos&" "&@OSServicePack, 16, 16, 300, 17) 
$Label2 = GUICtrlCreateLabel("系统分区:"& $windir, 16, 32, 120, 17) 
$Label3 = GUICtrlCreateLabel("分区格式:"& $windirp, 120, 32, 120, 17) 
$Label4 = GUICtrlCreateLabel("空间占用:"&$windirs, 224, 32, 120, 17) 
GUICtrlCreateGroup("", -99, -99, 1, 1) 
$Group2 = GUICtrlCreateGroup("功能选择:", 8, 56, 340, 97) 
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") 
$Label5 = GUICtrlCreateLabel("将分区:", 17, 76, 52, 17) 
$fromdisk = GUICtrlCreateCombo($hdinfofist&" "&$partnofist, 96, 72, 58, 30,$CBS_DROPDOWNLIST) 
$Label6 = GUICtrlCreateLabel("备份到:", 170, 76, 52, 17) 
$todisk = GUICtrlCreateCombo($hdinfolast&" "&$partnolast, 250, 72, 58, 30,$CBS_DROPDOWNLIST) 
$Label7 = GUICtrlCreateLabel($hdinfofist&"盘已用空间:"&(Round(DriveSpaceTotal($windir)) - Round(DriveSpaceFree($windir))) & "M", 17, 100, 150, 17,$WS_DISABLED) 
$Label8 = GUICtrlCreateLabel($hdinfolast&"盘可用空间:"& Round(DriveSpaceFree($hdinfolast)) & "M", 170, 100, 150, 17,$WS_DISABLED) 
$Label9 = GUICtrlCreateLabel("备份文件名:", 16, 124, 76, 17) 
$ghostname = GUICtrlCreateInput($bfpart&"\GHOST\"&StringLeft($windir,1)&"_"&$winsys, 96, 120, 121, 21,$ES_READONLY) 
GUICtrlSetTip(-1, $bfpart&"\GHOST\"&StringLeft($windir,1)&"_"&$winsys&".GHO") 
$Label10 = GUICtrlCreateLabel(".GHO", 224, 124, 31, 17) 
$ghorar = GUICtrlCreateCombo("", 256, 120, 73, 25,$CBS_DROPDOWNLIST) 
GUICtrlSetFont($GhoRAR, 9, 400, 0, "宋体") 
GUICtrlSetData($GhoRAR, "不压缩|快速压缩|高压缩|最高压缩","快速压缩") 
GUICtrlCreateGroup("", -99, -99, 1, 1) 
$btok = GUICtrlCreateButton("确定(&O)", 160, 160, 75, 25, 0) 
$cancel = GUICtrlCreateButton("关闭(&C)", 256, 160, 75, 25, 0) 
$Label11 = GUICtrlCreateLabel("程序: QQ:78357343", 8, 168, 130, 17) 
GUISetState(@SW_SHOW) 
#EndRegion ### END Koda GUI section ### 
; 
;获硬盘分区代码部份 
While 1 
$nMsg = GUIGetMsg() 
Switch $nMsg 
Case $GUI_EVENT_CLOSE 
Exit 
case $fromdisk 
$getfrom=GUICtrlRead($fromdisk) 
$fromleft=StringLeft($getfrom,2) 
$getto=GUICtrlRead($todisk) 
$toleft=StringLeft($getto,2) 
if $fromleft=$toleft Then 
MsgBox(64,"警告!","备份分区与镜像存放分区不能是同一分区!!",5) 
GUICtrlSetData($fromdisk,$hdinfofist&" "&$partnofist,$hdinfofist&" "&$partnofist) 
Else 
if $fromleft = $windir then 
GUICtrlSetData ($ghostname,$toleft&"\GHOST\"&StringLeft($fromleft,1)&"_"&$winsys) 
GUICtrlSetTip($ghostname, $toleft&"\GHOST\"&StringLeft($fromleft,1)&"_"&$winsys&".GHO") 
Else 
GUICtrlSetData ($ghostname,$toleft&"\GHOST\"&StringLeft($fromleft,1)&"_DATA") 
GUICtrlSetTip($ghostname, $toleft&"\GHOST\"&StringLeft($fromleft,1)&"_DATA.GHO") 
EndIf 
GUICtrlSetData($Label7, $fromleft & "盘已用空间:" & (Round(DriveSpaceTotal($fromleft)) - Round(DriveSpaceFree($fromleft))) & "M") 
EndIf 
case $todisk 
$getto=GUICtrlRead($todisk) 
$toleft=StringLeft($getto,2) 
$getfrom=GUICtrlRead($fromdisk) 
$fromleft=StringLeft($getfrom,2) 
if $fromleft=$toleft Then 
MsgBox(64,"警告!","备份分区与镜像存放分区不能是同一分区!!",5) 
GUICtrlSetData($todisk,$hdinfolast&" "&$partnolast,$hdinfolast&" "&$partnolast) 
Else 
if $fromleft = $windir then 
GUICtrlSetData ($ghostname,$toleft&"\GHOST\"&StringLeft($fromleft,1)&"_"&$winsys) 
GUICtrlSetTip($ghostname, $toleft&"\GHOST\"&StringLeft($fromleft,1)&"_"&$winsys&".GHO") 
Else 
GUICtrlSetData ($ghostname,$toleft&"\GHOST\"&StringLeft($fromleft,1)&"_DATA") 
GUICtrlSetTip($ghostname, $toleft&"\GHOST\"&StringLeft($fromleft,1)&"_DATA.GHO") 
EndIf 
GUICtrlSetData($Label8, $toleft & "盘已用空间:" & (Round(DriveSpaceTotal($toleft)) - Round(DriveSpaceFree($toleft))) & "M") 
EndIf 
$getfrom=GUICtrlRead($fromdisk) 
$ghostsys=$getfrom 

CASE $btok 
$getGhoRAR=GUICtrlRead($GhoRAR) 
Select   
Case $getGhoRAR="不压缩" 
$grar="" 
Case $getGhoRAR="快速压缩" 
$grar="-z1" 
case $getGhoRAR="高压缩" 
$grar="-z3" 
case $getGhoRAR="最高压缩" 
$grar="-z9" 
EndSelect 
$getbakname1=GUICtrlRead($ghostname) 
$getfrom=GUICtrlRead($fromdisk) 
$srcform=StringRight($getfrom,3) 
$getto=GUICtrlRead($todisk) 
$dstto=StringRight($getto,3) 
$dsttopart=StringLeft($getto,2) 
$sumname=StringLen($getbakname1) 
$getbakname=StringRight($getbakname1,$sumname-2) 

$finddir=FileFindFirstFile ($dsttopart&"\GHOST") 
if $finddir=-1 then 
DirCreate ($dsttopart&"\GHOST") 
EndIf 

$ghostbat="ghost.exe -nousb -clone,mode=pdump,src="& $srcform &",dst="& $dstto & $getbakname & ".zero -sure -fro -rb " &$grar   ;备份批处理生存 
;$ghostrebat="ghost -clone,mode=pload,src=1:"& $dstto & $getbakname&":1,dst=1:"& $srcform &" -sure -no1394 -nousb -rb"   
if FileExists(@HomeDrive &"\ZeroDOS\ZeroDOSbk.bat") Then FileDelete(@HomeDrive &"\ZeroDOS\ZeroDOSbk.bat") 
if FileExists(@HomeDrive &"\ZeroDOS\ZeroDOSre.bat") Then FileDelete(@HomeDrive &"\ZeroDOS\ZeroDOSre.bat") 
if FileExists(@SystemDir & "\diskinfo.dll") Then FileDelete(@SystemDir & "\diskinfo.dll") 

if not FileExists(@HomeDrive &"\ZeroDOS\ZeroDOSbk.bat") Then FileWrite(@HomeDrive &"\ZeroDOS\ZeroDOSbk.bat",$ghostbat) 
;if not FileExists(@HomeDrive &"\ZeroDOS\ZeroDOSre.bat") Then FileWrite(@HomeDrive &"\ZeroDOS\ZeroDOSre.bat",$ghostrebat) 
if FileExists(@HomeDrive &"\grldr") then FileCopy(@HomeDrive &"\grldr",@HomeDrive &"\ZeroDOS\grldr.bak") 
if not FileExists(@HomeDrive &"\grldr") Then FileInstall("grldr",@HomeDrive &"\grldr",1) 
;if not FileExists(@HomeDrive &"\bcft.gz") Then FileInstall("fonts.gz",@HomeDrive &"\ZeroDOS\fonts.gz",1)   ;字库 
;if not FileExists(@HomeDrive &"\ZeroDOS\zrdosbj.gz") Then FileInstall("zrdosbj.gz",@HomeDrive &"\ZeroDOS\zrdosbj.gz",1)   ;背景图 
if not FileExists(@HomeDrive &"\ZeroDOS\Memdisk.gz") Then FileInstall("Memdisk.gz",@HomeDrive &"\ZeroDOS\Memdisk.gz",1) 
if not FileExists(@HomeDrive &"\ZeroDOS\Zerodos.img") Then FileInstall("Zerodos.img",@HomeDrive &"\ZeroDOS\Zerodos.img",1);一键备份还原工具 
if not FileExists(@HomeDrive &"\ZeroDOS\zrdos.gz") Then FileInstall("zrdos.gz",@HomeDrive &"\ZeroDOS\zrdos.gz",1);一键备份还原菜单 
if not FileExists(@HomeDrive &"\ZeroDOS\ghost.exe") Then FileInstall("ghost.exe",@HomeDrive &"\ZeroDOS\ghost.exe",1);一键备份还原 
if not FileExists(@HomeDrive &"\ZeroDOS\ghost.bat") Then FileInstall("ghost.bat",@HomeDrive &"\ZeroDOS\ghost.bat",1);一键备份还原 
FileSetAttrib("c:\boot.ini", "-SHR") 
FileCopy("c:\boot.ini", "c:\zerodos\boot.bak") 
IniWrite("c:\boot.ini", "boot loader", "timeout", 1) 
IniWrite("c:\boot.ini", "boot loader", "default", "C:\grldr") 
IniWrite("c:\boot.ini", "operating systems", "C:\grldr", "ZeroOneKey Ghost 11") 

$msg = MsgBox(8192 + 0 + 64 + 4, "是否重启", "要重启计算机立即进行一键恢复吗?") 
If $msg = 6 Then 
if FileExists(@SystemDir & "\diskinfo.dll") Then FileDelete(@SystemDir & "\diskinfo.dll") 
if FileExists(@SystemDir & "\SkinCrafterDll.dll") Then FileDelete(@SystemDir & "\SkinCrafterDll.dll") 
if FileExists(@SystemDir & "\logo.jpg") Then FileDelete(@SystemDir & "\logo.jpg") 
if FileExists(@SystemDir & "\biosclub.ico") Then FileDelete(@SystemDir & "\biosclub.ico") 
Shutdown(2) 
Else 
if FileExists(@SystemDir & "\diskinfo.dll") Then FileDelete(@SystemDir & "\diskinfo.dll") 
if FileExists(@SystemDir & "\SkinCrafterDll.dll") Then FileDelete(@SystemDir & "\SkinCrafterDll.dll") 
if FileExists(@SystemDir & "\logo.jpg") Then FileDelete(@SystemDir & "\logo.jpg") 
if FileExists(@SystemDir & "\biosclub.ico") Then FileDelete(@SystemDir & "\biosclub.ico") 
       FileCopy("c:\zerodos\boot.bak","c:\boot.ini",1) 
FileSetAttrib("c:\boot.ini","+RSH") 
DirRemove("c:\zerodos",1) 
FileDelete("c:\grldr") 
if FileExists(@HomeDrive &"\ZeroDOS\grldr.bak") then filecopy(@HomeDrive &"\ZeroDOS\grldr.bak",@HomeDrive&"\grldr") 
Exit 
EndIf 
       case $cancel 
       Exit 
EndSwitch 
WEnd 
   
EndFunc 

Func restore() 

EndFunc 

;以下为皮肤用的 
Func _SkinGUI($SkincrafterDll, $SkincrafterSkin, $Handle) 
$Dll = DllOpen($SkincrafterDll) 
DllCall($Dll, "int:cdecl", "InitLicenKeys", "wstr",0, "wstr", "", "wstr", "", "wstr", "", "wstr", "") 
DllCall($Dll, "int:cdecl", "InitDecoration", "int", 1) 
DllCall($Dll, "int:cdecl", "LoadSkinFromFile", "wstr", $SkincrafterSkin) 
DllCall($Dll, "int:cdecl", "DecorateAs", "int", $Handle, "int", 25) 
DllCall($Dll, "int:cdecl", "ApplySkin") 
EndFunc    ;==_SkinGUI 

Func Quit() 
GUISetState(@SW_HIDE) 
DllCall($dll, "int", "DeInitDecoration") 
DllCall($dll, "int", "RemoveSkin") 
DllClose($dll) 
Exit 
EndFunc 



请帮忙看看这代码,除了皮肤外还需要哪些,注意是转载的!!
  请调试好的回个帖子!!
顺便把东东都传上来!!

[ 本帖最后由 xgdjkk 于 2008-7-24 16:16 编辑 ]
发表于 2008-10-27 23:13:40 | 显示全部楼层

恢复功能还不完善

差几个调用文件
发表于 2012-1-30 09:03:37 | 显示全部楼层
那位能补充一下!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-22 19:44 , Processed in 0.084491 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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