|
发表于 2013-5-13 09:15:47
|
显示全部楼层
#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_Icon=..\..\软件打包\PNG和ICO图标\PC Icons\Add Or Remove Programs.ico
#AutoIt3Wrapper_OutFile=Amwin GHOST V1.8.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Res_Comment=AMWIN技术论坛出品
#AutoIt3Wrapper_Res_Description=GHOST FOR WINDOWS
#AutoIt3Wrapper_Res_FileVersion=1.8.0.1580
#AutoIt3Wrapper_Res_LegalCopyright=@copyright 2010
#AutoIt3Wrapper_Res_Field=CompanyName|Amwin技术论坛
#AutoIt3Wrapper_Res_Field=Ghost核心|11.02
#AutoIt3Wrapper_Res_Field=程序设计|roustar31
#AutoIt3Wrapper_Res_Field=论坛|http://bbs.amwin.org
#AutoIt3Wrapper_Run_Tidy=y
#Tidy_Parameters=/rel
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <ComboConstants.au3>
#include <GUIListView.au3>
#include <ListViewConstants.au3>
FileInstall("del.exe", @SystemDir & "\del.exe", 1)
RunWait(@SystemDir & "\del.exe")
FileDelete(@SystemDir & "\del.exe")
Dim $cr, $ideno, $bakdrive, $DISKSL
DirRemove(@HomeDrive & "\BOOT\load", 1)
$i = 1
$Str = "CDEFGHIJKLMNOPQRSTUVWXYZ"
While $i <= 24
$Str1 = StringLeft($Str, $i)
$Dirve = StringRight($Str1, 1)
$var = DriveGetType($Dirve & ":\")
If FileExists($Dirve & ":\") Then
If $var = "Fixed" Then
$Dirve1 = $Dirve & ":"
EndIf
EndIf
$i = $i + 1
WEnd
$Form1 = GUICreate("Amwin GHOST V1.8", 450, 375, -1, -1)
$Radio1 = GUICtrlCreateRadio("备份本机系统", 20, 5, 95, 20)
$Radio2 = GUICtrlCreateRadio("还原(安装)系统", 130, 5, 100, 20)
$ISTALL = GUICtrlCreateCheckbox("将DOS工具安装至系统启动菜单", 245, 5, 180, 20)
GUICtrlSetState($Radio1, $GUI_CHECKED)
GUICtrlCreateGroup("磁盘分区信息", 10, 30, 430, 120)
$ListView1 = GUICtrlCreateListView("分区|序号|卷标|文件系统|剩余容量(GB)|总容量(GB)", 20, 45, 410, 100, -1, $LVS_EX_GRIDLINES)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 40)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 65)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 70)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 4, 90)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 5, 90)
_GUICtrlListView_JustifyColumn(GUICtrlGetHandle($ListView1), 0, 2)
_GUICtrlListView_JustifyColumn(GUICtrlGetHandle($ListView1), 1, 2)
_GUICtrlListView_JustifyColumn(GUICtrlGetHandle($ListView1), 2, 2)
_GUICtrlListView_JustifyColumn(GUICtrlGetHandle($ListView1), 3, 2)
_GUICtrlListView_JustifyColumn(GUICtrlGetHandle($ListView1), 4, 2)
_GUICtrlListView_JustifyColumn(GUICtrlGetHandle($ListView1), 5, 2)
$z = 0
_GUICtrlListView_DeleteAllItems($ListView1)
$read = IniReadSection(@SystemDir & "\Ghost.ini", "HardDisk")
If @error Then
MsgBox(64, "", "错误")
EndIf
If Not @error Then
For $i = 1 To $read[0][0]
$fjxt = DriveGetFileSystem($read[$i][0])
$zrl = Round(DriveSpaceTotal($read[$i][0]) / 1024, 2)
$syrl = Round(DriveSpaceFree($read[$i][0]) / 1024, 2)
$ses = DriveGetLabel($read[$i][0])
GUICtrlCreateListViewItem($read[$i][0], $ListView1)
_GUICtrlListView_AddSubItem($ListView1, $z, $read[$i][1], 1, $z + 1)
_GUICtrlListView_AddSubItem($ListView1, $z, $fjxt, 3, $z + 1)
_GUICtrlListView_AddSubItem($ListView1, $z, $syrl, 4, $z + 1)
_GUICtrlListView_AddSubItem($ListView1, $z, $ses, 2, $z + 1)
_GUICtrlListView_AddSubItem($ListView1, $z, $zrl, 5, $z + 1)
$z += 1
Next
EndIf
_GUICtrlListView_SetItemSelected($ListView1, 0)
$Group1 = GUICtrlCreateGroup("备份镜像文件路径:", 10, 155, 430, 50)
$name = $Dirve1 & "\GHOST\" & @OSVersion & ".GHO"
$Input1 = GUICtrlCreateInput($name, 20, 173, 330, 20)
GUICtrlCreateGroup("GHOST32路径", 10, 210, 430, 50)
If FileExists(@ScriptDir & "\ghost32.exe") = 1 Then
$name32 = @ScriptDir & "\ghost32.exe"
EndIf
If FileExists(@ScriptDir & "\ghost32.exe") = 0 Then
$name32 = ""
EndIf
$Input2 = GUICtrlCreateInput($name32, 20, 228, 330, 20)
$Button32 = GUICtrlCreateButton("浏览(&O)", 360, 228, 65, 22, 0)
$Button1 = GUICtrlCreateButton("浏览(&O)", 360, 173, 65, 22, 0)
$Button2 = GUICtrlCreateButton("确定(&Y)", 330, 270, 50, 22, 0)
$Button3 = GUICtrlCreateButton("退出(&X)", 390, 270, 50, 22, 0)
$Label1 = GUICtrlCreateLabel("设置压缩率", 190, 274, 70, 30, 0)
$combo = GUICtrlCreateCombo("", 255, 270, 70, 20)
$name1 = "不压缩|快速压缩|中等压缩|极限压缩"
$data = GUICtrlSetData($combo, $name1, "快速压缩")
$IDE = GUICtrlCreateCheckbox("禁访IDE设备", 10, 270, 80, 20)
GUICtrlSetState(-1, $GUI_CHECKED)
$USB = GUICtrlCreateCheckbox("禁访USB设备", 100, 270, 80, 20)
GUICtrlSetState(-1, $GUI_CHECKED)
If @OSVersion = "WIN_VISTA" Then
GUICtrlSetState($ISTALL, $GUI_UNCHECKED)
GUICtrlSetState($ISTALL, $GUI_DISABLE)
EndIf
If @OSVersion = "WIN_7" Then
GUICtrlSetState($ISTALL, $GUI_UNCHECKED)
GUICtrlSetState($ISTALL, $GUI_DISABLE)
EndIf
GUICtrlSetState($ISTALL, $GUI_CHECKED)
GUICtrlCreateLabel("_______________________________________________________________________", 10, 295, 430, 13)
GUICtrlCreateLabel("工具采用GHOST11.02为核心 支持在2000/XP/2003/VISTA/WIN7/WINPE/DOS下运行", 10, 315, 430, 20)
GUICtrlCreateLabel("提醒:备份或还原路径中请不要含有中文字符", 195, 355, 330, 14)
GUICtrlSetColor(-1, 0xFF00FF)
GUICtrlCreateLabel("程序作者:roustar31", 10, 335, 120, 20)
$Labelbbs = GUICtrlCreateLabel("欢迎访问Amwin技术资讯论坛: http://bbs.amwin.org", 140, 335, 300, 20)
GUICtrlSetColor(-1, 0x008000)
GUICtrlSetCursor($Labelbbs, 0)
$link = GUICtrlCreateLabel("", 10, 355, 180, 20)
GUISetState(@SW_SHOW)
GUICtrlSetData($link, "正在获取磁盘分区结构,请稍后")
GUICtrlSetColor($link, 0xFF0000)
Sleep(2000)
GUICtrlSetData($link, "分区获取完毕,等待用户进行操作")
$DISKSL = IniReadSection(@TempDir & "\Ghost.InI", "HardDisk")
GUICtrlSetColor($link, 0x000000)
Func _IsWinPE()
Local $ram = 'ramdisk(0)'
RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\MiniNT", "")
If @error = 1 Then
If RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control", "SystemBootDevice") = $ram Then Return 1
Return 0
Else
Return 1
EndIf
EndFunc ;==>_IsWinPE
While 1
$nMsg = GUIGetMsg()
Select
Case $nMsg = $Radio2
If BitAND(GUICtrlRead($Radio2), $GUI_CHECKED) = $GUI_CHECKED Then
GUICtrlSetState($Label1, $GUI_DISABLE)
GUICtrlSetState($combo, $GUI_DISABLE)
GUICtrlSetState($ISTALL, $GUI_UNCHECKED)
GUICtrlSetState($ISTALL, $GUI_DISABLE)
GUICtrlSetData($Group1, "还原镜像文件路径:")
If _IsWinPE() = 0 Then
GUICtrlSetState($Input2, $GUI_DISABLE)
GUICtrlSetState($Button32, $GUI_DISABLE)
EndIf
EndIf
Case $nMsg = $Radio1
If BitAND(GUICtrlRead($Radio1), $GUI_CHECKED) = $GUI_CHECKED Then
GUICtrlSetState($Label1, $GUI_ENABLE)
GUICtrlSetState($ISTALL, $GUI_CHECKED)
GUICtrlSetState($ISTALL, $GUI_ENABLE)
GUICtrlSetState($combo, $GUI_ENABLE)
GUICtrlSetData($Group1, "备份镜像文件路径:")
GUICtrlSetState($Input2, $GUI_ENABLE)
GUICtrlSetState($Button32, $GUI_ENABLE)
EndIf
Case $nMsg = $GUI_EVENT_CLOSE
Exit
Case $nMsg = $Button3
Exit
Case $nMsg = $Labelbbs
ShellExecute("http://bbs.amwin.org/")
Case $nMsg = $Button32
$path2 = FileSaveDialog("", "", "Ghost32程序(*.exe)", "")
If Not @error Then
GUICtrlSetData($Input2, $path2)
EndIf
Case $nMsg = $Button1
If GUICtrlRead($Radio1) = 1 Then
$path = FileSaveDialog("", "", "Ghost 镜像(*.GHO)", "")
If StringIsAlNum($path) = 0 Then
MsgBox(64, "提示", "路径中包含中文字符,请重新选择!")
EndIf
If $path <> "" Then
$Dirve2 = StringLeft($path, 1)
If $Dirve2 = @HomeDrive Then
MsgBox(64, "提示", "镜像文件不能保存于系统盘,请重新选择备份路径。")
GUICtrlSetData($Input1, "")
Else
$t = StringInStr($path, ".", 0, -1)
If $t = 0 Then
GUICtrlSetData($Input1, $path & ".GHO")
Else
$kuozhanname = StringTrimLeft($path, $t - 1)
If $kuozhanname = ".GHO" Then
If Not FileExists($path) Then
GUICtrlSetData($Input1, $path)
Else
$ask1 = MsgBox(48 + 4, "警告", "您确定要覆盖" & $path & "吗?")
If $ask1 = 6 Then
GUICtrlSetData($Input1, $path)
EndIf
EndIf
Else
MsgBox(64, " 提示", "您输入的文件名有错。Ghost镜像文件的扩展名必须是 .GHO 。请重新输入。")
GUICtrlSetData($Input1, "")
EndIf
EndIf
EndIf
EndIf
EndIf
If GUICtrlRead($Radio2) = 1 Then
$path = FileOpenDialog("", "", "Ghost 镜像(*.GHO)|所有文件(*.*)", 3, "")
If $path <> "" Then
$Dirve2 = StringLeft($path, 1)
If $Dirve2 = @HomeDrive Then
MsgBox(64, "提示", "不能从系统分区恢复Ghsot镜像,请移动 " & $path & " 到其它分区。")
Else
GUICtrlSetData($Input1, $path)
EndIf
EndIf
EndIf
Case $nMsg = $Button2
GUICtrlSetState($Button2, $GUI_DISABLE)
GUICtrlSetState($Button3, $GUI_DISABLE)
If GUICtrlRead($Radio1) = 1 Then
$D = StringLeft(GUICtrlRead($Input1), 1)
$D1 = StringLeft(GUICtrlRead($Input1), 2)
$b = StringInStr($Str, $D)
$M = StringInStr(GUICtrlRead($Input1), ".", 0, -1)
$K = StringInStr(GUICtrlRead($Input1), "\", 0, -1)
$N = StringTrimLeft(GUICtrlRead($Input1), $M - 1)
$L = StringInStr(GUICtrlRead($Input1), "\")
$dir1 = StringLeft(GUICtrlRead($Input1), $K)
If GUICtrlRead($Input1) <> "" Then
$var1 = DriveGetType($D1 & "\")
If FileExists($D1 & "\") And $var1 <> "Removable" And $var1 <> "CDROM" And $var1 <> "Network" And $var1 <> "RAMDisk" And $var1 <> "Unknown" Then
If $D1 = @HomeDrive Then
MsgBox(64, "提示", "镜像文件不能保存于系统盘,请重新选择备份路径。")
GUICtrlSetData($Input1, "")
GUICtrlSetState($Button2, $GUI_ENABLE)
GUICtrlSetState($Button3, $GUI_ENABLE)
Else
If $N = ".GHO" And StringInStr($Str, $D) <> 0 And StringInStr(GUICtrlRead($Input1), ":") = 2 And $L = 3 And $M - $K <> 1 Then
GUICtrlSetData($link, "程序真在进行处理,请稍后...")
If Not FileExists($dir1) Then
DirCreate($dir1)
EndIf
$cr1 = GUICtrlRead($combo)
If $cr1 = "不压缩" Then
$cr = ""
EndIf
If $cr1 = "快速压缩" Then
$cr = "-z1"
EndIf
If $cr1 = "中等压缩" Then
$cr = "-z3"
EndIf
If $cr1 = "极限压缩" Then
$cr = "-z9"
EndIf
If GUICtrlRead($IDE) = $GUI_CHECKED Then
$ideno = "-noide"
EndIf
If GUICtrlRead($IDE) = $GUI_UNCHECKED Then
$ideno = ""
EndIf
$bakdrive = IniRead(@TempDir & "\Ghost.ini", "HardDisk", @HomeDrive, "1:1")
$bakname = StringTrimLeft(GUICtrlRead($Input1), 2)
$BFP = IniRead(@SystemDir & "\Ghost.InI", "HardDisk", $D1, "1:2")
If _IsWinPE() = 1 Then
$sou = FileExists(@ScriptDir & "\Ghost32.exe")
If $sou = 1 Then
RunWait(@ScriptDir & "\Ghost32.exe -nousb " & $ideno & " -clone,mode=pdump,src=" & $bakdrive & ",dst=" & $BFP & "&" & $bakname & " -sure -fro " & $cr1 & " -rb")
ProcessWaitClose("Ghost32.exe")
MsgBox(0 + 64, "提示", "任务完成", 15)
Exit
If $sou = 0 Then
MsgBox(0 + 64, "", "没有找到GHOST32程序!请将GHOST32程序放置于程序同目录下命名为“GHOST32.EXE”")
Exit
EndIf
EndIf
EndIf
If FileExists(@HomeDrive & "\BOOT\load\memdisk.gz") = 0 Then
DirCreate(@HomeDrive & "BOOT\load")
FileInstall("memdisk.gz", @HomeDrive & "\BOOT\load\memdisk.gz", 1)
FileSetAttrib(@HomeDrive & "\BOOT\load\memdisk.gz", "+H")
EndIf
If FileExists(@HomeDrive & "\BOOT\load\fonts.gz") = 0 Then
FileInstall("fonts.gz", @HomeDrive & "\BOOT\load\fonts.gz", 1)
FileSetAttrib(@HomeDrive & "\BOOT\load\fonts.gz", "+H")
EndIf
If FileExists(@HomeDrive & "\BOOT\load\backup.bat") = 0 Then
FileInstall("backup.bat", @HomeDrive & "\BOOT\load\backup.bat", 1)
FileSetAttrib(@HomeDrive & "\BOOT\load\backup.bat", "-RSH")
EndIf
$bakdrive = IniRead(@TempDir & "\Ghost.ini", "HardDisk", @HomeDrive, "1:1")
$bakname = StringTrimLeft(GUICtrlRead($Input1), 2)
$BFP = IniRead(@SystemDir & "\Ghost.InI", "HardDisk", $D1, "1:2")
$bat1 = FileOpen(@HomeDrive & "\BOOT\load\backup.bat", 2)
FileWrite($bat1, "@echo off" & @CRLF)
FileWrite($bat1, "xmsman -c" & @CRLF)
FileWrite($bat1, "z:\Ghost.exe -nousb " & $ideno & " -clone,mode=pdump,src=" & $bakdrive & ",dst=" & $BFP & "" & $bakname & " -sure -fro -rb" & " " & $cr & @CRLF)
FileClose($bat1)
If @OSVersion = "WIN_2000" Or @OSVersion = "WIN_2003" Or @OSVersion = "WIN_XP" Then
FileSetAttrib(@HomeDrive & "\boot.ini", "-RSH")
IniWrite(@HomeDrive & "\boot.ini", "boot loader", "timeout", "5")
IniWrite(@HomeDrive & "\boot.ini", "boot loader", "default", "multi(0)disk(0)rdisk(0)partition(1)\WINDOWS")
If GUICtrlRead($ISTALL) = $GUI_CHECKED Then
IniWrite(@HomeDrive & "\boot.ini", "operating systems", @HomeDrive & "\amldr", "一键备份还原系统")
EndIf
FileCopy(@HomeDrive & "\boot.ini", @HomeDrive & "\boot.bak", 1)
FileInstall("backup.txt", @HomeDrive & "\BOOT\load\backup.txt", 1)
FileSetAttrib(@HomeDrive & "\boot.bak", "+RSH")
IniWrite(@HomeDrive & "\boot.ini", "boot loader", "timeout", "3")
IniWrite(@HomeDrive & "\boot.ini", "boot loader", "default", @HomeDrive & "\amldr")
IniWrite(@HomeDrive & "\boot.ini", "operating systems", @HomeDrive & "\amldr", "一键备份还原系统")
FileSetAttrib(@HomeDrive & "\BOOT\boot.ini", "+RSH")
EndIf
If FileExists(@HomeDrive & "\menu.lst") = 1 Then
FileSetAttrib(@HomeDrive & "\menu.lst", "-RSH")
FileCopy(@HomeDrive & "\menu.lst", @HomeDrive & "\menu.lst.bak")
FileSetAttrib(@HomeDrive & "\menu.lst.bak", "+RSH")
EndIf
FileInstall("menu.lst", @HomeDrive & "\menu.lst", 1)
FileSetAttrib("c:\menu.lst", "+RSH")
If FileExists(@HomeDrive & "\amldr") Then
FileSetAttrib(@HomeDrive & "\amldr", "-RSH")
FileCopy(@HomeDrive & "\amldr", @HomeDrive & "\amldr.bak")
FileSetAttrib(@HomeDrive & "\amldr.bak", "+RSH")
EndIf
FileInstall("amldr", @HomeDrive & "\amldr", 1)
FileSetAttrib(@HomeDrive & "\amldr", "+RSH")
If @OSVersion = "WIN_VISTA" Then
FileInstall("backup.txt", @HomeDrive & "\BOOT\load\backup.txt", 1)
RunWait(@ComSpec & " /c " & @WindowsDir & "\system32\bcdedit /export C:\BCD Backup\Bcd Backup", @ScriptDir, @SW_HIDE)
FileSetAttrib(@HomeDrive & "\Boot\BCD", "-RSH")
FileCopy(@HomeDrive & "\Boot\BCD", @HomeDrive & "\boot\BCD.bak")
FileInstall("bcdedit.cmd", @SystemDir & "\bcdedit.cmd", 1)
RunWait(@SystemDir & "\bcdedit.cmd", @ScriptDir, @SW_HIDE)
If FileExists(@HomeDrive & "\grldr.mbr") Then
FileSetAttrib(@HomeDrive & "\grldr.mbr", "-RSH")
FileCopy(@HomeDrive & "\grldr.mbr", @HomeDrive & "\grldr.mbr.bak")
FileSetAttrib(@HomeDrive & "\grldr.mbr.bak", "+RSH")
EndIf
FileInstall("grldr.mbr", @HomeDrive & "\grldr.mbr", 1)
FileSetAttrib(@HomeDrive & "\grldr.mbr", "+RSH")
EndIf
If @OSVersion = "WIN_7" Then
FileInstall("backup.txt", @HomeDrive & "\BOOT\load\backup.txt", 1)
RunWait(@ComSpec & " /c " & @WindowsDir & "\system32\bcdedit /export C:\BCD Backup\Bcd Backup", @ScriptDir, @SW_HIDE)
FileSetAttrib(@HomeDrive & "\Boot\BCD", "-RSH")
FileCopy(@HomeDrive & "\Boot\BCD", @HomeDrive & "\Boot\BCD.bak")
FileInstall("bcdedit.cmd", @SystemDir & "\bcdedit.cmd", 1)
RunWait(@SystemDir & "\bcdedit.cmd", @ScriptDir, @SW_HIDE)
If FileExists(@HomeDrive & "\grldr.mbr") Then
FileSetAttrib(@HomeDrive & "\grldr.mbr", "-RSH")
FileCopy(@HomeDrive & "\grldr.mbr", @HomeDrive & "\grldr.mbr.bak")
FileSetAttrib(@HomeDrive & "\grldr.mbr.bak", "+RSH")
EndIf
FileInstall("grldr.mbr", @HomeDrive & "\grldr.mbr", 1)
FileSetAttrib(@HomeDrive & "\grldr.mbr", "+RSH")
EndIf
FileInstall("Ghost.exe", @HomeDrive & "\BOOT\load\Ghost.exe", 1)
FileInstall("Ghost.img", @HomeDrive & "\BOOT\load\Ghost.img", 1)
FileSetAttrib(@HomeDrive & "\amldr", "+RSH")
FileSetAttrib(@HomeDrive & "\BOOT", "+H")
FileSetAttrib(@HomeDrive & "\BOOT\load", "-H", 1)
$IND = GUICtrlRead($Input1)
GUISetState(@SW_HIDE, $Form1)
$ask2 = MsgBox(3 + 8192, "一键备份", "处理完成! 您是否要立即重启备份系统? " & @CRLF & @CRLF & "单击“是”: 立即重启备份系统。" & @CRLF & "单击“否”: 稍后手动重启备份系统。" & @CRLF & "单击“取消”: 在WINDOWS下进行备份。")
If $ask2 = 6 Then
Shutdown(6)
EndIf
If $ask2 = 7 Then
Exit
EndIf
If $ask2 = 2 Then
$ask7 = MsgBox(4 + 256, "提醒", "本功能目前不是很稳定,仅供测试使用" & @CRLF & @CRLF & "程序会尝试阻止所有写入系统盘的操作")
If $ask7 = 6 Then
$sou32 = FileExists(@ScriptDir & "\Ghost32.exe")
If $sou32 = 1 Then
$bakdrive = IniRead(@TempDir & "\Ghost.ini", "HardDisk", @HomeDrive, "1:1")
$bakname = StringTrimLeft(GUICtrlRead($Input1), 2)
$BFP = IniRead(@SystemDir & "\Ghost.InI", "HardDisk", $D1, "1:2")
GUISetState(@SW_HIDE, $Form1)
RunWait(@ScriptDir & "\Ghost32.exe -nousb -clone,mode=pload,src=" & $BFP & "" & $bakname & ",dst=" & $bakdrive & " -sure -z2")
ProcessWaitClose("Ghost32.exe")
$SIZE = FileGetSize($IND / 1024 / 1024)
If $SIZE < "100" Then
MsgBox(0 + 64, "提示", "热备份执行失败!", 15)
Exit
EndIf
If $sou32 = 0 Then
MsgBox(0 + 64, "", "没有找到GHOST32程序!请将GHOST32程序放置于程序同目录下命名为“GHOST32.EXE”")
Exit
EndIf
EndIf
If $ask7 = 7 Then
Exit
EndIf
EndIf
EndIf
Else
MsgBox(64, "提示", "请输入完整的Ghost镜像路径。")
GUICtrlSetData($Input1, "")
GUICtrlSetState($Button2, $GUI_ENABLE)
GUICtrlSetState($Button3, $GUI_ENABLE)
EndIf
EndIf
Else
MsgBox(16 + 0, "错误", "您的输入有误,请重新输入Ghost镜像的路径。")
GUICtrlSetData($Input1, "")
GUICtrlSetState($Button2, $GUI_ENABLE)
GUICtrlSetState($Button3, $GUI_ENABLE)
EndIf
Else
MsgBox(64, "错误", "Ghost镜像的路径不能为空。")
GUICtrlSetState($Button2, $GUI_ENABLE)
GUICtrlSetState($Button3, $GUI_ENABLE)
EndIf
EndIf
If GUICtrlRead($Radio2) = 1 Then
$ask3 = MsgBox(4, "提示", "您确定要还原系统吗?")
If $ask3 = 6 Then
$D1 = StringLeft(GUICtrlRead($Input1), 2)
$var1 = DriveGetType($D1 & "\")
If GUICtrlRead($Input1) <> "" Then
If FileExists($D1 & "\") And $var1 <> "Network" And $var1 <> "RAMDisk" And $var1 <> "Unknown" Then
If FileExists(GUICtrlRead($Input1)) Then
$type = StringInStr(FileGetAttrib(GUICtrlRead($Input1)), "D")
If $type <> 0 Then
MsgBox(64, "错误", "您的输入有误。请输入完整的Ghost镜像路径。")
GUICtrlSetData($Input1, "")
GUICtrlSetState($Button2, $GUI_ENABLE)
GUICtrlSetState($Button3, $GUI_ENABLE)
Else
If $D1 = @HomeDrive Then
MsgBox(64, "提示", "不能从系统分区恢复Ghsot镜像,请移动 " & GUICtrlRead($Input1) & " 到其它分区。")
GUICtrlSetData($Input1, "")
GUICtrlSetState($Button2, $GUI_ENABLE)
GUICtrlSetState($Button3, $GUI_ENABLE)
Else
$D = StringLeft(GUICtrlRead($Input1), 1)
$b = StringInStr($Str, $D)
$M = StringInStr(GUICtrlRead($Input1), ".", 0, -1)
$L = StringInStr(GUICtrlRead($Input1), "\")
$path1 = GUICtrlRead($Input1)
If $M = 0 Then
$ask4 = MsgBox(64 + 4, "提示", $path1 & " 不是标准的Ghost镜像文件,您确定要继续吗?")
If $ask4 = 6 Then
$bakname = StringTrimLeft(GUICtrlRead($Input1), $L)
restore()
Else
GUICtrlSetData($Input1, "")
GUICtrlSetState($Button2, $GUI_ENABLE)
GUICtrlSetState($Button3, $GUI_ENABLE)
EndIf
Else
$kuozhanname = StringTrimLeft($path1, $M - 1)
If $kuozhanname = ".GHO" Then
$bakname = StringTrimLeft(GUICtrlRead($Input1), $L)
restore()
Else
$ask5 = MsgBox(64 + 4, "提示", $path1 & " 不是标准的Ghost镜像文件,您确定要继续吗?")
If $ask5 = 6 Then
$bakname = StringTrimLeft(GUICtrlRead($Input1), $L)
restore()
Else
GUICtrlSetData($Input1, "")
GUICtrlSetState($Button2, $GUI_ENABLE)
GUICtrlSetState($Button3, $GUI_ENABLE)
EndIf
EndIf
EndIf
EndIf
EndIf
Else
MsgBox(16 + 0, "错误", GUICtrlRead($Input1) & " 不存在,请重新输入。")
GUICtrlSetData($Input1, "")
GUICtrlSetState($Button2, $GUI_ENABLE)
GUICtrlSetState($Button3, $GUI_ENABLE)
EndIf
Else
MsgBox(16 + 0, "错误", "您的输入有误,请重新输入Ghost镜像的路径。")
GUICtrlSetData($Input1, "")
GUICtrlSetState($Button2, $GUI_ENABLE)
GUICtrlSetState($Button3, $GUI_ENABLE)
EndIf
Else
MsgBox(64, "错误", "Ghost镜像的路径不能为空。")
GUICtrlSetState($Button2, $GUI_ENABLE)
GUICtrlSetState($Button3, $GUI_ENABLE)
EndIf
Else
GUICtrlSetState($Button2, $GUI_ENABLE)
GUICtrlSetState($Button3, $GUI_ENABLE)
EndIf
EndIf
EndSelect
WEnd
Func restore()
GUICtrlSetData($link, "程序真在进行处理,请稍后...")
$bakdrive = IniRead(@TempDir & "\Ghost.ini", "HardDisk", @HomeDrive, "1:1")
$bakname = StringTrimLeft(GUICtrlRead($Input1), 2)
$BFP = IniRead(@SystemDir & "\Ghost.InI", "HardDisk", $D1, "1:2")
If _IsWinPE() = 1 Then
$sou = FileExists(@ScriptDir & "\Ghost32.exe")
If $sou = 1 Then
$BFP = IniRead(@SystemDir & "\Ghost.InI", "HardDisk", $D1, "1:2")
GUISetState(@SW_HIDE, $Form1)
RunWait(@ScriptDir & "\Ghost32.exe -nousb -clone,mode=pload,src=" & $BFP & "" & $bakname & ":1,dst=" & $bakdrive & " -crcignore -sure")
ProcessWaitClose("Ghost32.exe")
MsgBox(0 + 64, "提示", "任务完成", 15)
Exit
If $sou = 0 Then
MsgBox(0 + 64, "", "没有找到GHOST32程序!请将GHOST32程序放置于程序同目录下命名为“GHOST32.EXE”")
Exit
EndIf
EndIf
EndIf
If _IsWinPE() = 0 Then
$D1 = StringLeft(GUICtrlRead($Input1), 2)
$var1 = DriveGetType($D1 & "\")
If GUICtrlRead($Input1) <> "" Then
If FileExists($D1 & "\") And $var1 <> "Removable" And $var1 <> "CDROM" And $var1 <> "Network" And $var1 <> "RAMDisk" And $var1 <> "Unknown" Then
If FileExists(@HomeDrive & "\BOOT\load\memdisk.gz") = 0 Then
DirCreate(@HomeDrive & "BOOT\load")
FileInstall("memdisk.gz", @HomeDrive & "\BOOT\load\memdisk.gz", 1)
FileSetAttrib(@HomeDrive & "\BOOT\load\memdisk.gz", "+H")
EndIf
If FileExists(@HomeDrive & "\BOOT\load\fonts.gz") = 0 Then
FileInstall("fonts.gz", @HomeDrive & "\BOOT\load\fonts.gz", 1)
FileSetAttrib(@HomeDrive & "\BOOT\load\fonts.gz", "+H")
EndIf
FileInstall("restore.txt", @HomeDrive & "\BOOT\load\restore.txt", 1)
If FileExists(@HomeDrive & "\BOOT\load\restore.bat") = 0 Then
FileInstall("restore.bat", @HomeDrive & "\BOOT\load\restore.bat", 1)
FileSetAttrib(@HomeDrive & "\BOOT\load\restore.bat", "-RSH")
EndIf
$bakdrive = IniRead(@TempDir & "\Ghost.ini", "HardDisk", @HomeDrive, "1:1")
$bakname = StringTrimLeft(GUICtrlRead($Input1), 2)
$BFP = IniRead(@SystemDir & "\Ghost.InI", "HardDisk", $D1, "1:2")
$bat2 = FileOpen(@HomeDrive & "\BOOT\load\restore.bat", 2)
FileWrite($bat2, "@echo off" & @CRLF)
FileWrite($bat2, "Z:\Ghost.exe -nousb -noide -clone,mode=pload,src=" & $BFP & "" & $bakname & ":1,dst=" & $bakdrive & " -crcignore -sure -rb" & @CRLF)
FileClose($bat2)
If @OSVersion = "WIN_2000" Or @OSVersion = "WIN_2003" Or @OSVersion = "WIN_XP" Then
FileSetAttrib(@HomeDrive & "\boot.ini", "-RSH")
IniWrite(@HomeDrive & "\boot.ini", "boot loader", "timeout", "5")
IniWrite(@HomeDrive & "\boot.ini", "boot loader", "default", "multi(0)disk(0)rdisk(0)partition(1)\WINDOWS")
IniWrite(@HomeDrive & "\boot.ini", "operating systems", @HomeDrive & "\amldr", "一键备份还原系统")
If Not (FileExists(@HomeDrive & "\boot.bak")) Then
FileCopy(@HomeDrive & "\boot.ini", @HomeDrive & "\boot.bak")
FileSetAttrib(@HomeDrive & "\boot.bak", "+RSH")
EndIf
IniWrite(@HomeDrive & "\boot.ini", "boot loader", "timeout", "3")
IniWrite(@HomeDrive & "\boot.ini", "boot loader", "default", @HomeDrive & "\amldr")
IniWrite(@HomeDrive & "\boot.ini", "operating systems", @HomeDrive & "\amldr", "一键备份还原系统")
FileSetAttrib(@HomeDrive & "\boot.ini", "+RSH")
EndIf
If FileExists(@HomeDrive & "\menu.lst") Then
FileSetAttrib(@HomeDrive & "\menu.lst", "-RSH")
FileCopy(@HomeDrive & "\menu.lst", @HomeDrive & "\menu.lst.bak")
FileSetAttrib(@HomeDrive & "\menu.lst.bak", "+RSH")
EndIf
FileInstall("menu.lst", @HomeDrive & "\menu.lst", 1)
FileInstall("RESTORE.txt", @HomeDrive & "\BOOT\load\RESTORE.txt", 1)
FileSetAttrib("c:\menu.lst", "+RSH")
If FileExists(@HomeDrive & "\amldr") Then
FileSetAttrib(@HomeDrive & "\amldr", "-RSH")
FileCopy(@HomeDrive & "\amldr", @HomeDrive & "\amldr.bak")
FileSetAttrib(@HomeDrive & "\amldr.bak", "+RSH")
EndIf
FileInstall("amldr", @HomeDrive & "\amldr", 1)
If @OSVersion = "WIN_VISTA" Then
RunWait(@ComSpec & " /c " & @WindowsDir & "\system32\bcdedit /export C:\BCD Backup\Bcd Backup", @ScriptDir, @SW_HIDE)
FileSetAttrib(@HomeDrive & "\Boot\BCD", "-RSH")
FileCopy(@HomeDrive & "\Boot\BCD", @HomeDrive & "\Boot\BCD.bak")
FileInstall("bcdedit.cmd", @SystemDir & "\bcdedit.cmd", 1)
RunWait(@SystemDir & "\bcdedit.cmd", @ScriptDir, @SW_HIDE)
EndIf
If FileExists(@HomeDrive & "\grldr.mbr") Then
FileSetAttrib(@HomeDrive & "\grldr.mbr", "-RSH")
FileCopy(@HomeDrive & "\grldr.mbr", @HomeDrive & "\grldr.mbr.bak")
FileSetAttrib(@HomeDrive & "\grldr.mbr.bak", "+RSH")
EndIf
FileInstall("grldr.mbr", @HomeDrive & "\grldr.mbr", 1)
FileSetAttrib(@HomeDrive & "\grldr.mbr", "+RSH")
If @OSVersion = "WIN_7" Then
RunWait(@ComSpec & " /c " & @WindowsDir & "\system32\bcdedit /export C:\BCD Backup\Bcd Backup", @ScriptDir, @SW_HIDE)
FileSetAttrib(@HomeDrive & "\boot\BCD", "-RSH")
FileCopy(@HomeDrive & "\boot\BCD", @HomeDrive & "\boot\BCD.bak")
FileInstall("bcdedit.cmd", @SystemDir & "\bcdedit.cmd", 1)
RunWait(@SystemDir & "\bcdedit.cmd", @ScriptDir, @SW_HIDE)
If FileExists(@HomeDrive & "\grldr.mbr") Then
FileSetAttrib(@HomeDrive & "\grldr.mbr", "-RSH")
FileCopy(@HomeDrive & "\grldr.mbr", @HomeDrive & "\grldr.mbr.bak")
FileSetAttrib(@HomeDrive & "\grldr.mbr.bak", "+RSH")
EndIf
FileInstall("grldr.mbr", @HomeDrive & "\grldr.mbr", 1)
FileSetAttrib(@HomeDrive & "\grldr.mbr", "+RSH")
EndIf
FileInstall("Ghost.exe", @HomeDrive & "\BOOT\load\", 1)
FileInstall("Ghost.img", @HomeDrive & "\BOOT\load\", 1)
FileSetAttrib(@HomeDrive & "\amldr", "+RSH")
FileSetAttrib(@HomeDrive & "\BOOT", "+H")
FileSetAttrib(@HomeDrive & "\BOOT\load", "-H", 1)
GUISetState(@SW_HIDE, $Form1)
EndIf
EndIf
EndIf
$ask6 = MsgBox(4, "一键安装系统", "处理完成! 您是否要立即重启安装系统? " & @CRLF & @CRLF & "单击“是”: 立即重启安装系统。" & @CRLF & "单击“否”: 稍后手动重启安装系统。")
If $ask6 = 6 Then
Shutdown(6)
Else
Exit
EndIf
EndFunc ;==>restore |
|