以下是源代码:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
FileInstall("7za.exe", @TempDir & "7za.exe", 1)
Global $time = 20
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("系统安装", 350, 142, 193, 125)
$pic=GUICtrlCreatePic(@ScriptDir&"\onekey.bmp",0,0,350,60)
GUICtrlSetFont(-1, 12, 400, 0, "楷体_GB2312")
$label2=GUICtrlCreateLabel("本操作将删除C盘数据,请确认硬盘已分区,并备份好了C盘数据!",3,65)
GUICtrlSetFont(-1, 9, 400, 0, "宋体")
$Progress1 = GUICtrlCreateProgress(8, 88, 333, 10)
$Button1 = GUICtrlCreateButton("确定(&Y)", 53, 110, 83, 25, 0)
$Button2 = GUICtrlCreateButton("退出(&X)", 210, 110, 73, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUICtrlCreateGroup('',0,54.5,356,10,$ss_etchedhorz)
AdlibRegister("_timer", 1000)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE, $Button2
Exit
Case $Button1
ExitLoop
EndSwitch
If $time <= 0 Then ExitLoop
WEnd
main()
Exit
Func _timer()
$time -= 1
GUICtrlSetData($Button1, "确定"&$time&"(&Y)");"秒后将恢复系统到C盘!"
GUICtrlSetData($Progress1, (20 - $time) / 0.2)
If $time <= 0 Then AdlibUnRegister()
EndFunc ;==>_timer
Func main()
Dim $CDRom, $i, $Target, $Drive, $Flag, $Flagr, $boot, $sysc
GUISetState(@SW_HIDE,$Form1)
$Target = "WINXPSP3.GHO"
$boot = "boot.ini"
For $i = 90 To 67 Step -1
$Drive = Chr($i)
If FileExists($Drive & ":\system\" & $Target) Then
$CDRom = $Drive & ":"
ExitLoop
EndIf
Next
If FileExists($CDRom) Then
If FileExists($CDRom & "\PESOFT\GHOST\Ghost32.exe") And FileExists($CDRom & "\system\WINXPSP3.GHO") Then
ToolTip(@CR & " 正在执行恢复XP到C盘,请稍候... " & @CR, @DesktopWidth - 260, @DesktopHeight - 120)
RunWait($CDRom & "\PESOFT\GHOST\Ghost32.exe -nousb -clone,mode=pload,src=" & $CDRom & "\system\WINXPSP3.GHO:1,dst=1:1 -crcignore -sure",$CDRom&"\")
ProcessWaitClose("Ghost32.exe")
;ToolTip("")
For $i = 90 To 67 Step -1
$drvc = Chr($i)
If FileExists($drvc & ":\" & $boot) Then
$sysc = $drvc & ":"
ExitLoop
EndIf
Next
ToolTip(@CR & " 正在复制驱动,请稍候... " & @CR, @DesktopWidth - 260, @DesktopHeight - 120)
Sleep(100)
;定义复制段
FileCopy($CDRom & "\dv.exe", $sysc & "\windows\dv\", 1)
FileCopy($CDRom & "\dvs.exe", $sysc & "\", 1)
$Flagr = MsgBox(1, "温馨提示:", "驱动复制完成,请重启电脑完成安装", 5)
If $Flagr = 2 Then
Exit
EndIf
Run(@ComSpec & " /c " & 'pecmd shut r', "", @SW_HIDE)
ElseIf Not FileExists($CDRom & "\PESOFT\GHOST\Ghost32.exe") Then
MsgBox(0, "Error", "未发现Ghost32.exe程序!")
Exit
ElseIf Not FileExists($CDRom & "\system\WINXPSP3.GHO") Then
MsgBox(0, "Error", "未发现gho系统镜像文件!")
Exit
EndIf
Else
MsgBox(0, "Error", "未发现gho系统镜像文件!")
Exit
EndIf
EndFunc ;==>main
我把代码编译成au3程序,在pe下点击运行,进入后点AU3程序执行任务可以把驱动复制到C盘任务全部完成,但是让AU3程序进入PE桌面后自动运行,au3只执行ghost任务,驱动就复制不了??这是怎么回事,请教一下大侠们,谢谢! |