#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_Icon=LOGO.ico
#PRE_Outfile=TOOLS.EXE
#PRE_Compression=4
#PRE_UseUpx=n
#PRE_Res_Comment=年老痴呆
#PRE_Res_Description=Windows 镜像工具
#PRE_Res_Fileversion=2.1.0.0
#PRE_Res_requestedExecutionLevel=None
#PRE_Res_Field=CompanyName|年老痴呆
#PRE_Res_Field=Ghost核心|11.02
#PRE_AU3Check_Stop_OnWarning=y
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
;#AutoIt3Wrapper_Run_Tidy=y
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <Array.au3>
#include <File.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <GUIListView.au3>
#include <ListViewConstants.au3>
$Form1 = GUICreate("Windows 镜像工具v2.1", 665, 360, -1, -1)
$Group = GUICtrlCreateGroup("搜索镜像名称及路径:", 435, 15, 220, 210)
$Combo = GUICtrlCreateList("", 445, 30, 200, 185, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
FileInstall("ShowDrive.Vxd", @SystemDir & "\ShowDrive.Vxd", 1)
FileInstall("DsptW.Vxd", @SystemDir & "\DsptW.Vxd", 1)
SplashTextOn("", "正在获取分区,请稍候...", 250, 38, -1, -1, 1, "", 10)
RUNWAIT ( @SystemDir & "\ShowDrive.Vxd /S" , @SystemDir , @SW_HIDE )
FILEDELETE(@SystemDir & "\ShowDrive.Vxd")
RUNWAIT ( @COMSPEC & " /C " & @SystemDir & "\DsptW.Vxd /A /Pdr >" & @SystemDir & "\Part.Txt" , @SystemDir , @SW_HIDE )
FILEDELETE(@SystemDir & "\DsptW.Vxd")
$IniFile =@SystemDir & "\Part.Txt"
$Ini=@SystemDir & "\Ghost.ini"
FILEDELETE($Ini)
FileWriteLine($Ini,"[HardDisk]")
For $i=3 To 26
$ReadFile=FileReadLine($IniFile,$i) ;第三行开始读取
If $ReadFile='' Then ExitLoop ;空退出
If StringMid($ReadFile,2,1)=":" Then ;$ReadFile第2字符为:
FileWriteLine(@SystemDir & "\P.Txt",StringLeft($ReadFile,8)) ;返回左起8个字符
EndIf
Next
FILEDELETE(@SystemDir & "\Part.Txt")
$Lines = _FileCountLines(@SystemDir & "\P.Txt") ;获取文本行数
For $y =1 To $Lines Step 1
$strExt = filereadline(@SystemDir & "\P.Txt",$y)
$strExt = StringStripWS($strExt,2)
$StrExt=StringRegExpReplace($StrExt,'\s','=') ;替换': '为'='
FileWriteLine($Ini,$StrExt)
Next
FILEDELETE(@SystemDir & "\P.Txt")
SplashOff()
FileInstall("gho.exe", @SystemDir & "\")
SplashTextOn("", "正在搜索gho文件,请稍候...", 250, 38, -1, -1, 1, "", 10)
RunWait(@SystemDir & "\gho.exe", @SystemDir & "\")
FileDelete(@SystemDir & "\gho.exe")
SplashOff()
$file = FileOpen(@SystemDir & "\gho.txt", 0)
$Files = @SystemDir & '\gho.txt'
$gho_path = FileReadLine($files, 1)
$Size = Round(FileGetSize($gho_path)/1024/1024,3)
Dim $aRecords
If _FileReadToArray($Files, $aRecords) Then
GUICtrlSetData($Combo, "")
For $x = 1 To $aRecords[0]
GUICtrlSetData($Combo, $aRecords[$x], $x)
Next
EndIf
GUICtrlCreateGroup("磁盘分区信息", 10, 15, 420, 210)
$ListView1 = GUICtrlCreateListView("分区|序号|卷标|文件系统|剩余容量(GB)|总容量(GB)", 20, 30, 400, 185, -1, $LVS_EX_GRIDLINES)
GUICtrlSeNDMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 40)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 45)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 60)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 65)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 4, 85)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 5, 80)
_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)
FileClose($file)
Dim $Dr
$Drive=DriveGetDrive("FIXED")
For $i = 1 To $Drive[0]
$Dr=StringUpper($Drive[$i])
Next
$Button1 = GUICtrlCreateButton("执行(&Y)", 360, 315, 70, 22, 0)
$Button2 = GUICtrlCreateButton("退出(&X)", 460, 315, 70, 22, 0)
$Label1 = GUICtrlCreateLabel("AM电脑吧", 560, 318, 100, 30, 0)
GUICtrlSetTip($Label1, "关于我们论坛")
GUICtrlSetCursor($Label1, 0)
$Group1 = GUICtrlCreateGroup("备份镜像路径:", 15, 245, 320, 50)
$name = $Dr & "\Ghost\" & @OSVersion & ".GHO"
$Input1 = GUICtrlCreateInput($name, 30, 265, 290, 20)
$Button3 = GUICtrlCreateButton("浏览(&F)", 360, 265, 70, 22, 0)
$Labelz = GUICtrlCreateLabel("镜像大小(MB):", 460, 268, 100, 30, 0)
$Labelzz = GUICtrlCreateLabel($Size, 560, 268, 100, 30, 0)
$Radio1 = GUICtrlCreateRadio("备份C盘系统", 30, 315, 100, 20)
$Radio2 = GUICtrlCreateRadio("还原系统到C盘", 180,315, 100, 20)
GUICtrlSetState($Radio1, $GUI_CHECKED)
GUICtrlSetState($Labelz, $GUI_DISABLE) ;灰色
GUICtrlSetState($Labelzz, $GUI_DISABLE) ;灰色
GUICtrlSetState($combo, $GUI_DISABLE) ;灰色
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Select
Case $nMsg = $GUI_EVENT_CLOSE
FileDelete(@SystemDir & "\gho.txt")
FileDelete(@SystemDir & "\Ghost.ini")
Exit
Case $nMsg = $Button2
FileDelete(@SystemDir & "\gho.txt")
FileDelete(@SystemDir & "\Ghost.ini")
Exit
Case $nMsg = $Label1
ShellExecute("https://www.ampc8.com/")
Case $nMsg = $Combo
$gho_path = GUICtrlRead($Combo)
If $gho_path <> "" Then
$Size = Round(FileGetSize($gho_path)/1024/1024,3)
GUICtrlSetData($Labelzz,$Size)
GUICtrlSetData($Input1, $gho_path)
EndIf
Case $nMsg = $Radio2 ;"还原系统到C盘"
If BitAND(GUICtrlRead($Radio2), $GUI_CHECKED) = $GUI_CHECKED Then
GUICtrlSetState($Labelz, $GUI_ENABLE) ;JiHuo
GUICtrlSetState($Labelzz, $GUI_ENABLE) ;JiHuo
GUICtrlSetState($combo, $GUI_ENABLE) ;JiHuo
GUICtrlSetData($Group1, "还原镜像文件路径:")
GUICtrlSetData($Input1, $gho_path)
EndIf
Case $nMsg = $Radio1 ; "备份C盘系统"
If BitAND(GUICtrlRead($Radio1), $GUI_CHECKED) = $GUI_CHECKED Then
GUICtrlSetState($Labelz, $GUI_DISABLE) ;灰色
GUICtrlSetState($Labelzz, $GUI_DISABLE) ;灰色
GUICtrlSetState($combo, $GUI_DISABLE) ;灰色
GUICtrlSetData($Group1, "备份镜像文件路径:")
GUICtrlSetData($Input1, $name)
EndIf
Case $nMsg = $Button3
If GUICtrlRead($Radio1)= $GUI_CHECKED Then
$path = FileSaveDialog("", "", "Ghost 镜像(*.GHO)", "")
If $path <> "" Then
$Dirve2 = StringLeft($path, 1)
If $Dirve2 = "C" Then
MsgBox(64, "提示", "镜像文件不能保存于 C 盘,请重新选择备份路径。")
GUICtrlSetData($Input1, "")
Else
If StringRight($path, 4) = ".GHO" Then
GUICtrlSetData($Input1, $path)
Else
GUICtrlSetData($Input1, $path &".GHO")
EndIf
$path = GUICtrlRead($Input1)
If FileExists($path) Then
$ask1 = MsgBox(48 + 4, "警告", "您确定要覆盖" & $path & "吗?")
If $ask1 = 6 Then
GUICtrlSetData($Input1, $path)
Else
GUICtrlSetData($Input1,"")
EndIf
Else
GUICtrlSetData($Input1, $path)
EndIf
EndIf
EndIf
EndIf
If GUICtrlRead($Radio2)= $GUI_CHECKED Then
$path = FileOpenDialog("查找", "", "镜像(*.gho)")
If $path <> "" Then
GUICtrlSetData($Input1,$path)
EndIf
EndIf
Case $nMsg = $Button1
If GUICtrlRead($Radio2) = $GUI_CHECKED Then ;"还原系统到C盘"
If Not FileExists(GUICtrlRead($Input1)) Then
MsgBox(0, "错误!", "没有找到可以还原的镜像!")
GUICtrlSetData($Input1,"")
Else
$D1 = StringLeft(GUICtrlRead($Input1), 2)
If $D1 ="C:" Then
MsgBox(0, "错误!", "你选择的镜像在“C”盘,不能恢复!")
GUICtrlSetData($Input1,"")
Else
GUICtrlSetState($Button1, $GUI_DISABLE)
$dir = @WindowsDir
$systemroot = StringRegExpReplace($dir, "(\S:).*$", "$1")
If StringLeft($systemroot, 2) = "X:" Then
$bakdrive = IniRead(@SystemDir & "\Ghost.ini", "HardDisk", @HomeDrive, "1:1")
$bakname = StringTrimLeft(GUICtrlRead($Input1), 2)
$BFP = IniRead(@SystemDir & "\Ghost.InI", "HardDisk", $D1, "1:2")
FileInstall("Ghost32.dll", @WindowsDir & "\GHOST32.EXE",1)
FileInstall("32.bat", @WindowsDir & "\32.bat",1)
$bat = FileOpen(@WindowsDir & "\32.bat", 2)
FileWrite($bat,"Ghost32.exe -nousb -noide -clone,mode=pload,src=" & $BFP & "" & $bakname & ":1,dst=" & $bakdrive & " -crcignore -sure")
FileClose($bat)
RunWait(@WindowsDir & "\32.bat", @SystemDir & "\", @SW_HIDE)
MsgBox(0, "安装系统", "安装系统完成!")
Exit
Else
GUICtrlSetState($Button1, $GUI_DISABLE)
RESTORE()
EndIf
EndIf
EndIf
EndIf
If GUICtrlRead($Radio1) = $GUI_CHECKED Then ; "备份C盘系统"
$D1 = StringLeft(GUICtrlRead($Input1), 2)
If $D1 ="C:" Then
MsgBox(0, "错误!", "镜像不能保存在“C”盘!")
GUICtrlSetData($Input1,"")
Else
$path = GUICtrlRead($Input1)
If StringRight($path, 4) = ".GHO" Then
$path = $path
Else
$path =$path&".GHO"
EndIf
$bName = stringsplit($path, "\" , 1 )
$name = $bName[$bName[0]]
$name1 = StringReplace($path,"\" & $name,"")
If StringRight($name1, 1) <> ":" Then
If Not FileExists($name1) Then
DirCreate($name1)
EndIf
EndIf
GUICtrlSetState($Button1, $GUI_DISABLE)
$dir = @WindowsDir
$systemroot = StringRegExpReplace($dir, "(\S:).*$", "$1")
If StringLeft($systemroot, 2) ="X:" Then
$bakdrive = IniRead(@SystemDir & "\Ghost.ini", "HardDisk", @HomeDrive, "1:1")
$bakname = StringTrimLeft($path, 2)
$BFP = IniRead(@SystemDir & "\Ghost.InI", "HardDisk", $D1, "1:2")
FileInstall("Ghost32.dll", @WindowsDir & "\GHOST32.EXE",1)
FileInstall("32.bat", @WindowsDir & "\32.bat",1)
$bat = FileOpen(@WindowsDir & "\32.bat", 2)
FileWrite($bat,"Ghost32.exe -nousb -noide -clone,mode=pdump,src=" & $bakdrive &",dst=" & $BFP & "" & $bakname & " -sure -fro -z9")
FileClose($bat)
RunWait(@WindowsDir & "\32.bat", @SystemDir & "\", @SW_HIDE)
MsgBox(0, "备份系统", "备份系统完成!")
Exit
Else
backup()
EndIf
EndIf
EndIf
EndSelect
WEnd
http://pan.baidu.com/share/link?shareid=3311698534&uk=922779640
|