Func _RESTORE()
$path = $downdir & "" & $sName
$D1 = StringLeft($path, 2)
If FileExists(@HomeDrive & "\dos.bat") = 0 Then
FileInstall("dos.bat", @HomeDrive & "\RESTORE.bat", 1)
FileSetAttrib(@HomeDrive & "\RESTORE.bat", "-RSH")
EndIf
$bakdrive = IniRead(@SystemDir & "\Ghost.ini", "HardDisk", @HomeDrive, "1:1")
$bakname = StringTrimLeft($downdir & "" & $sName, 2)
$BFP = IniRead(@SystemDir & "\Ghost.InI", "HardDisk", $D1, "1:2")
$bat2 = FileOpen(@HomeDrive & "\RESTORE.bat", 2)
FileWrite($bat2, "@echo off" & @CRLF)
FileWrite($bat2, "xmsman -c" & @CRLF)
FileWrite($bat2, "Z:\Ghost.exe -nousb -noide -clone,mode=pload,src=" & $BFP & "" & $bakname & ":1,dst=" & $bakdrive & " -crcignore -sure -rb" & @CRLF)
FileClose($bat2)
FileSetAttrib(@HomeDrive & "\RESTORE.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 & "\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")
RunWait(@ComSpec & " /c " & @WindowsDir & "\system32\bcdedit /export C:\bcd.dna", @ScriptDir, @SW_HIDE)
FileInstall("bcdedit.cmd", @SystemDir & "\bcdedit.cmd", 1)
RunWait(@ComSpec & " /c " & @SystemDir & "\bcdedit.cmd", @SystemDir, @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")
RunWait(@ComSpec & " /c " & @WindowsDir & "\system32\bcdedit /export C:\bcd.dna", @ScriptDir, @SW_HIDE)
FileInstall("bcdedit.cmd", @SystemDir & "\bcdedit.cmd", 1)
RunWait(@ComSpec & " /c " & @SystemDir & "\bcdedit.cmd", @SystemDir, @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 & "\Ghost.exe", 1)
FileInstall("ghost.img", @HomeDrive & "\ghost.img", 1)
FileSetAttrib(@HomeDrive & "\Ghost.exe", "+RSH")
FileSetAttrib(@HomeDrive & "\ghost.img", "+RSH")
FileSetAttrib(@HomeDrive & "\BOOT", "+H")
FileDelete(@SystemDir & "\Ghost.ini")
GUISetState(@SW_HIDE, $Form1)
GUISetState(@SW_HIDE, $Form2)
$ask6 = MsgBox(4, "", "程序准备就绪! 您是否要立即重装系统? " & @CRLF & @CRLF & "单击“是”: 立即重启安装系统。" & @CRLF & "单击“否”: 稍后手动重启安装系统。")
If $ask6 = 6 Then
Shutdown(6)
;ElseIf $ask6 = 7 Then
;GUISetState(@SW_SHOW, $Form2)
EndIf
EndFunc ;==>_RESTORE