#NoTrayIcon
#region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_Icon=LOGO.ico
#AutoIt3Wrapper_Outfile=Jxwglm-Pe.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Res_Comment=江夏网管联盟论坛
#AutoIt3Wrapper_Res_Description=系统备份与还原
#AutoIt3Wrapper_Res_Fileversion=1.8.0.1580
#AutoIt3Wrapper_Res_LegalCopyright=@copyright 2012
#AutoIt3Wrapper_Res_Field=CompanyName|DeepinYin制作
#AutoIt3Wrapper_Res_Field=Ghost核心|11.02
#AutoIt3Wrapper_Run_Tidy=y
#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("config.exe", @SystemDir & "\config.exe", 1)
RunWait(@SystemDir & "\config.exe")
FileDelete(@SystemDir & "\config.exe")
Dim $cr, $ideno, $bakdrive, $DISKSL
$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
;===================装载程序所需文件完成
#region ### START Koda GUI section ### Form=C:\Documents and Settings\Administrator\桌面\雨林木风PE硬盘安装器\XP 硬盘安装器.kxf
$Form1 = GUICreate("江夏网管联盟硬盘安装工具 FOR PE", 409, 262, 235, 176)
$Group1 = GUICtrlCreateGroup("", 7, 8, 386, 193, -1, $WS_EX_TRANSPARENT);列表框架1,无需设置
$Group2 = GUICtrlCreateGroup("", 7, 96, 386, 105);列表框架2,无需设置
;==================================================================================================================================================
$Label2 = GUICtrlCreateLabel("选择系统安装分区:", 16, 24, 112, 21)
$BFCombo2 = GUICtrlCreateCombo("", 123, 24, 100, 25)
$BFVar1 = DriveGetDrive("FIXED")
If Not @error Then
For $Var1i = 1 To $BFVar1[0]
GUICtrlSetData(-1, $BFVar1[$Var1i], "c:")
Next
EndIf;此段获取系统分区信息
$Checkbox1 = GUICtrlCreateCheckbox("格式化(F)", 240, 26, 97, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
;==================================================================================================================================================
$Radio1 = GUICtrlCreateRadio("GHOST备份(B)", 16, 64, 121, 17)
GUICtrlSetState($Radio1, $GUI_CHECKED);设置默认选择
$Radio2 = GUICtrlCreateRadio("GHOST还原(S)", 148, 64, 113, 17)
$Radio3 = GUICtrlCreateRadio("硬盘版安装(I)", 280, 64, 105, 17)
;==================================================================================================================================================
$Label1 = GUICtrlCreateLabel("GHO/I386安装文件路径选择:", 16, 120, 170, 21)
$Button1 = GUICtrlCreateButton("浏览(S)", 310, 149, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$name = $Dirve1 & "\GHOST" & @OSVersion & ".GHO";定义备份的文件类型为"GHO"
$Input1 = GUICtrlCreateInput($name, 16, 152, 281, 21)
;==================================================================================================================================================
$Button2 = GUICtrlCreateButton("确定(O)", 112, 211, 75, 25)
$Button3 = GUICtrlCreateButton("退出(X)", 200, 211, 75, 25)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
;==================================================================================================================================================
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button3
Exit
Case $nMsg = $GUI_EVENT_CLOSE
FileDelete(@SystemDir & "\config.exe")
FileDelete(@SystemDir & "\Ghost.ini")
Exit
Case $nMsg = $Button3
FileDelete(@SystemDir & "\config.exe")
FileDelete(@SystemDir & "\Ghost.ini")
Exit
Case $nMsg = $Button1
If GUICtrlRead($Radio1) = 1 Then
$path = FileSaveDialog("", "", "Ghost 镜像(*.GHO)", "")
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
If Not FileExists($dir1) Then
DirCreate($dir1)
EndIf
If FileExists(@HomeDrive & "\dos.bat") = 0 Then
FileInstall("dos.bat", @HomeDrive & "\dos.bat", 1)
FileSetAttrib(@HomeDrive & "\dos.bat", "-RSH")
EndIf
$bakname = StringTrimLeft(GUICtrlRead($Input1), 2)
$BFP = IniRead(@SystemDir & "\Ghost.InI", "HardDisk", $D1, "1:2")
$bat1 = FileOpen(@HomeDrive & "\dos.bat", 2)
FileWrite($bat1, "@echo off" & @CRLF)
FileWrite($bat1, "Ghost.exe -nousb " & $ideno & " -clone,mode=pdump,src=" & $bakdrive & ",dst=" & $BFP & "" & $bakname & " -sure -fro -rb" & " " & $cr & @CRLF)
FileWrite($bat1, "A:\R.COM")
FileClose($bat1)
FileSetAttrib(@HomeDrive & "\dos.bat", "+H")
If @OSVersion = "WIN_2000" Or @OSVersion = "WIN_2003" Or @OSVersion = "WIN_XP" Then
FileSetAttrib(@HomeDrive & "\boot.ini", "-RSH")
FileCopy(@HomeDrive & "\boot.ini", @HomeDrive & "\boot.dna", 1)
FileSetAttrib(@HomeDrive & "\boot.dna", "+RSH")
IniWrite(@HomeDrive & "\boot.ini", "boot loader", "timeout", "0")
IniWrite(@HomeDrive & "\boot.ini", "boot loader", "default", @HomeDrive & "\grldr")
IniWrite(@HomeDrive & "\boot.ini", "operating systems", @HomeDrive & "\grldr", "一键备份系统")
FileSetAttrib(@HomeDrive & "\boot.ini", "+RSH")
EndIf
If FileExists(@HomeDrive & "\menu.lst") Then
FileSetAttrib(@HomeDrive & "\menu.lst", "-RSH")
FileCopy(@HomeDrive & "\menu.lst", @HomeDrive & "\lst.dna")
FileSetAttrib(@HomeDrive & "\lst.dna", "+RSH")
FileDelete(@SystemDir & "\menu.lst")
EndIf
If FileExists(@HomeDrive & "\grldr") Then
FileSetAttrib(@HomeDrive & "\grldr", "-RSH")
FileCopy(@HomeDrive & "\grldr", @HomeDrive & "\grldr.dna")
FileSetAttrib(@HomeDrive & "\grldr.dna", "+RSH")
EndIf
FileInstall("grldr", @HomeDrive & "\grldr", 1)
FileSetAttrib(@HomeDrive & "\grldr", "+RSH")
If @OSVersion = "WIN_VISTA" Then
FileSetAttrib(@HomeDrive & "\boot", "-RSH")
DirRemove(@HomeDrive & "\BOOT\load", 1)
FileInstall("backup.txt", @HomeDrive & "\BOOT\load", 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 & "\BCD.dna")
FileInstall("bcdedit.cmd", @SystemDir & "\bcdedit.cmd", 1)
RunWait(@SystemDir & "\bcdedit.cmd", @ScriptDir, @SW_HIDE)
If FileExists(@HomeDrive & "\grldr.mbr") = 1 Then
FileSetAttrib(@HomeDrive & "\grldr.mbr", "-RSH")
FileCopy(@HomeDrive & "\grldr.mbr", @HomeDrive & "\mbr.dna")
FileSetAttrib(@HomeDrive & "\mbr.dna", "+RSH")
EndIf
FileInstall("grldr.mbr", @HomeDrive & "\grldr.mbr", 1)
FileSetAttrib(@HomeDrive & "\grldr.mbr", "+RSH")
EndIf
If @OSVersion = "WIN_7" Then
FileSetAttrib(@HomeDrive & "\boot", "-RSH")
DirRemove(@HomeDrive & "\BOOT\load", 1)
FileInstall("backup.txt", @HomeDrive & "\BOOT\load", 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 & "\BCD.dna")
FileInstall("bcdedit.cmd", @SystemDir & "\bcdedit.cmd", 1)
RunWait(@SystemDir & "\bcdedit.cmd", @ScriptDir, @SW_HIDE)
If FileExists(@HomeDrive & "\grldr.mbr") = 1 Then
FileSetAttrib(@HomeDrive & "\grldr.mbr", "-RSH")
FileCopy(@HomeDrive & "\grldr.mbr", @HomeDrive & "\mbr.dna")
FileSetAttrib(@HomeDrive & "\mbr.dna", "+RSH")
EndIf
FileInstall("grldr.mbr", @HomeDrive & "", 1)
FileSetAttrib(@HomeDrive & "\grldr.mbr", "+RSH")
EndIf
FileInstall("Ghost.exe", @HomeDrive & "", 1)
FileInstall("ghost.img", @HomeDrive & "", 1)
FileSetAttrib(@HomeDrive & "\ghost.img", "+H")
FileSetAttrib(@HomeDrive & "Ghost.exe", "+H")
FileSetAttrib(@HomeDrive & "\BOOT", "+H")
$IND = GUICtrlRead($Input1)
GUISetState(@SW_HIDE, $Form1)
$ask2 = MsgBox(3 + 8192, "一键备份", "处理完成! 您是否要立即重启备份系统? " & @CRLF & @CRLF & "单击“是”: 立即重启备份系统。" & @CRLF & "单击“否”: 稍后手动重启备份系统。" & @CRLF & "单击“取消”: 在WINDOWS下进行备份。")
If $ask2 = 6 Then
Shutdown(6)
Else
Exit
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
EndSwitch
WEnd
Func restore()
If FileExists(@HomeDrive & "\dos.bat") = 0 Then
FileInstall("dos.bat", @HomeDrive & "\dos.bat", 1)
FileSetAttrib(@HomeDrive & "\dos.bat", "-RSH")
EndIf
$bakname = StringTrimLeft(GUICtrlRead($Input1), 2)
$BFP = IniRead(@SystemDir & "\Ghost.InI", "HardDisk", $D1, "1:2")
$bat2 = FileOpen(@HomeDrive & "\dos.bat", 2)
FileWrite($bat2, "@echo off" & @CRLF)
FileWrite($bat2, "Ghost.exe -nousb -noide -clone,mode=pload,src=" & $BFP & "" & $bakname & ":1,dst=" & $bakdrive & " -crcignore -sure -rb" & @CRLF)
FileWrite($bat2, "A:\R.COM")
FileClose($bat2)
FileSetAttrib(@HomeDrive & "\dos.bat", "+RSH")
If @OSVersion = "WIN_2000" Or @OSVersion = "WIN_2003" Or @OSVersion = "WIN_XP" Then
FileSetAttrib(@HomeDrive & "\boot.ini", "-RSH")
If Not (FileExists(@HomeDrive & "\boot.dna")) Then
FileCopy(@HomeDrive & "\boot.ini", @HomeDrive & "\boot.dna")
FileSetAttrib(@HomeDrive & "\boot.dna", "+RSH")
EndIf
IniWrite(@HomeDrive & "\boot.ini", "boot loader", "timeout", "0")
IniWrite(@HomeDrive & "\boot.ini", "boot loader", "default", @HomeDrive & "\grldr")
IniWrite(@HomeDrive & "\boot.ini", "operating systems", @HomeDrive & "\grldr", "一键还原系统")
FileSetAttrib(@HomeDrive & "\boot.ini", "+RSH")
EndIf
If FileExists(@HomeDrive & "\menu.lst") Then
FileSetAttrib(@HomeDrive & "\menu.lst", "-RSH")
FileCopy(@HomeDrive & "\menu.lst", @HomeDrive & "\lst.dna")
FileSetAttrib(@HomeDrive & "\lst.dna", "+RSH")
FileDelete(@SystemDir & "\menu.lst")
EndIf
If FileExists(@HomeDrive & "\grldr") Then
FileSetAttrib(@HomeDrive & "\grldr", "-RSH")
FileCopy(@HomeDrive & "\grldr", @HomeDrive & "\grldr.dna")
FileSetAttrib(@HomeDrive & "\grldr.dna", "+RSH")
EndIf
FileInstall("grldr", @HomeDrive & "", 1)
FileSetAttrib(@HomeDrive & "\grldr", "+RSH")
If @OSVersion = "WIN_VISTA" Then
FileSetAttrib(@HomeDrive & "\boot", "-RSH")
DirRemove(@HomeDrive & "\BOOT\load", 1)
FileInstall("backup.txt", @HomeDrive & "\BOOT\load", 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 & "\BCD.dna")
FileInstall("bcdedit.cmd", @SystemDir & "\bcdedit.cmd", 1)
RunWait(@SystemDir & "\bcdedit.cmd", @ScriptDir, @SW_HIDE)
If FileExists(@HomeDrive & "\grldr.mbr") = 1 Then
FileSetAttrib(@HomeDrive & "\grldr.mbr", "-RSH")
FileCopy(@HomeDrive & "\grldr.mbr", @HomeDrive & "\mbr.dna")
FileSetAttrib(@HomeDrive & "\mbr.dna", "+RSH")
EndIf
FileInstall("grldr.mbr", @HomeDrive & "\grldr.mbr", 1)
FileSetAttrib(@HomeDrive & "\grldr.mbr", "+RSH")
EndIf
If @OSVersion = "WIN_7" Then
FileSetAttrib(@HomeDrive & "\boot", "-RSH")
DirRemove(@HomeDrive & "\BOOT\load", 1)
FileInstall("backup.txt", @HomeDrive & "\BOOT\load", 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 & "\BCD.dna")
FileInstall("bcdedit.cmd", @SystemDir & "\bcdedit.cmd", 1)
RunWait(@SystemDir & "\bcdedit.cmd", @ScriptDir, @SW_HIDE)
If FileExists(@HomeDrive & "\grldr.mbr") = 1 Then
FileSetAttrib(@HomeDrive & "\grldr.mbr", "-RSH")
FileCopy(@HomeDrive & "\grldr.mbr", @HomeDrive & "\mbr.dna")
FileSetAttrib(@HomeDrive & "\mbr.dna", "+RSH")
EndIf
FileInstall("grldr.mbr", @HomeDrive & "\grldr.mbr", 1)
FileSetAttrib(@HomeDrive & "\grldr.mbr", "+RSH")
EndIf
FileInstall("Ghost.exe", @HomeDrive & "", 1)
FileInstall("ghost.img", @HomeDrive & "", 1)
FileSetAttrib(@HomeDrive & "\Ghost.exe", "+RSH")
FileSetAttrib(@HomeDrive & "\ghost.img", "+RSH")
FileSetAttrib(@HomeDrive & "\BOOT", "+H")
GUISetState(@SW_HIDE, $Form1)
$ask6 = MsgBox(4, "一键安装系统", "处理完成! 您是否要立即重启安装系统? " & @CRLF & @CRLF & "单击“是”: 立即重启安装系统。" & @CRLF & "单击“否”: 稍后手动重启安装系统。")
If $ask6 = 6 Then
Shutdown(6)
Else
Exit
EndIf
EndFunc ;==>restore