找回密码
 加入
搜索
楼主: ndyndy

[原创] wim系统镜像安装与制作(nt 50/60 通用)

 火... [复制链接]
发表于 2013-8-17 23:04:20 | 显示全部楼层
参考参考。谢谢了
发表于 2013-8-17 23:08:53 | 显示全部楼层
参考参考。谢谢了
发表于 2013-9-12 20:28:45 | 显示全部楼层
有源码吗.....
发表于 2014-12-28 19:42:15 | 显示全部楼层
这个不错,来学习了
发表于 2015-2-7 15:10:03 | 显示全部楼层
回复 1# ndyndy


    不错啊!正需要了
发表于 2015-2-7 15:14:14 | 显示全部楼层
回复 1# ndyndy


    楼主,为什么下载不了?
发表于 2015-2-7 15:26:37 | 显示全部楼层
小手一招,经验带走,附件无法下载。谢谢
发表于 2015-2-7 16:41:39 | 显示全部楼层
回复 1# ndyndy


    楼主能不能提供源码?
发表于 2015-2-7 16:41:55 | 显示全部楼层
回复 1# ndyndy


    楼主能不能提供源码?我真的很需要!
发表于 2015-3-5 09:49:26 | 显示全部楼层
回复 1# ndyndy


    用了段时间,感觉楼主编写的这个软件特别好!
 楼主| 发表于 2015-3-6 10:34:58 | 显示全部楼层
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=ico.ico
#AutoIt3Wrapper_outfile=Z:\C\tools\wim\bbzwim.exe
#AutoIt3Wrapper_Res_Comment=笨笨朱制作
#AutoIt3Wrapper_Res_Description=系统镜像安装制作  笨笨朱
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****

#include <ComboConstants.au3>
#include <TabConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIComboBox.au3>
#include <GuiConstantsEx.au3>
#include <Constants.au3>
#include <GUIListBox.au3>
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <Process.Au3>
#include <StaticConstants.au3>
#include <EditConstants.au3>
#include <Constants.au3>
#include <StaticConstants.au3>
#include <ProgressConstants.au3>
;#include "DirInstall_udf.au3"
#include <GUIConstantsEx.au3>


Global $Image[40], $LevelInfo[40], $LevelDiscrip[40], $BUILD[40], $SPBUILD[40], $FullInfo[40], $Langue[40], $imgvol[40]
Global $FileNum, $FilePath, $ImageFIle,$Parameter,$ver
Global $PageNum = 1, $LevelForm, $Levelgroup, $LevelView, $SelectMoreButton, $SelectNextButton, $SelectCancelButton, $Levelgroup2, $LevelLabel, $Label4, $Label5


Global $DosTool = @TempDir & '\DsptW.eXe'
Global $IniFile = @TempDir & '\DskVol.InI'
Global $ShowDrive = @TempDir & '\ShowDrive.eXe'
Global $ComLine = $DosTool & ' /A /Pdr >' & $IniFile
Global $DiskForm, $DiskGroup, $DiskList, $DiskNextButton, $DiskCancelButton, $diskgroup2, $diskcheck, $DiskRadio1, $DiskRadio2, $DiskCombo, $DiskRadio3

Global $LevelMode, $DiskPar, $ActivePar, $TarPar, $TarLan, $FormMode, $OldRead,$wim2
Global $progressform, $add, $clear, $mylist, $Button1, $nmsg, $EditPage = 2, $BootRes = 0, $FixRes = 0, $ChangeRes = 0, $Progress1, $ProLabe1, $ProLabe2, $ProLabe3, $Label7, $Label8, $ProButton1, $ProButton2, $ProgressEdit

Global $w[24], $q[4]
Global $wim1, $wim2, $selectwim

#Region ### START Koda GUI section ### Form=d:\downloads\autoit脚本\wim安装\temp\wim安装.kxf
$Form1_1 = GUICreate("笨笨朱  WIM镜像安装与制作", 354, 387, 311, 203)
$Tab1 = GUICtrlCreateTab(0, 0, 353, 385, -1, $TCS_EX_FLATSEPARATORS)
GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("镜 像 安 装")
$Label1 = GUICtrlCreateLabel("2.选择分区(盘符)", 21, 104, 109, 17)
$_disk1 = GUICtrlCreateCombo("", 21, 124, 297, 22, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
$Label2 = GUICtrlCreateLabel("1.选择映像文件", 21, 54, 85, 17)
$_wimimg = GUICtrlCreateCombo("", 21, 174, 297, 22, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
$Label3 = GUICtrlCreateLabel("3.选择需安装的镜像", 21, 154, 109, 17)
$Progress1 = GUICtrlCreateProgress(21, 224, 297, 15)
GUICtrlSetState(-1, $GUI_HIDE)
$Label4 = GUICtrlCreateLabel("文件解压进度:", 22, 204, 152, 17)
$Label6 = GUICtrlCreateLabel("引导文件修复:", 21, 253, 152, 17)
$Label7 = GUICtrlCreateLabel("系统文件修正:", 21, 275, 152, 17)
$Label8 = GUICtrlCreateLabel("系统盘符修正:", 21, 299, 152, 17)
$_exit = GUICtrlCreateButton("退 出", 134, 341, 57, 25, $WS_GROUP)
$_sysfix = GUICtrlCreateButton("引导修复", 194, 341, 57, 25, $WS_GROUP)
$_install = GUICtrlCreateButton("安装执行", 254, 341, 57, 25, $WS_GROUP)
$Label5 = GUICtrlCreateLabel("剩余时间: --:--", 182, 204, 137, 17)
$brow1 = GUICtrlCreateButton("浏览", 279, 74, 39, 22, $WS_GROUP)
$_wimfile1 = GUICtrlCreateInput("", 21, 74, 257, 22)
$Group1 = GUICtrlCreateGroup("目标分区操作选择", 205, 250, 113, 73)
$DiskRadio1 = GUICtrlCreateRadio("格式化", 213, 274, 113, 17)
GUICtrlSetState(-1, $Gui_Checked)
$DiskRadio2 = GUICtrlCreateRadio("保留原有文件", 213, 298, 113, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$TabSheet2 = GUICtrlCreateTabItem("新制和追加")
$Label9 = GUICtrlCreateLabel("1.选择分区(盘符)", 21, 54, 109, 17)
$_disk2 = GUICtrlCreateCombo("", 21, 74, 297, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
$Label10 = GUICtrlCreateLabel("2.选择映像文件", 21, 104, 85, 17)
$Label11 = GUICtrlCreateLabel("3.镜像描述", 21, 154, 61, 17)
$Label12 = GUICtrlCreateLabel("文件压制进度:", 22, 204, 152, 17)
$_exit2 = GUICtrlCreateButton("退 出", 134, 341, 57, 25, $WS_GROUP)
$_wiadd = GUICtrlCreateButton("镜像追加", 194, 341, 57, 25, $WS_GROUP)
$_wimmak = GUICtrlCreateButton("新制映像", 254, 341, 57, 25, $WS_GROUP)
$Progress2 = GUICtrlCreateProgress(21, 224, 297, 15)
GUICtrlSetState(-1, $GUI_HIDE)
$Label16 = GUICtrlCreateLabel("剩余时间: --:--", 182, 204, 137, 17)
$_wimfile2 = GUICtrlCreateInput("", 21, 124, 257, 22)
$brow2 = GUICtrlCreateButton("浏览", 279, 124, 39, 22, $WS_GROUP)
$_wimvol = GUICtrlCreateInput("", 19, 174, 297, 22)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$ActivePar = ''
FileInstall('DsptW.eXe', @TempDir & '\DsptW.eXe', 1)
FileInstall('ShowDrive.eXe', @TempDir & '\ShowDrive.eXe', 1)
TrayTip("操作过程", "正在检测本地硬盘", 3)
If Not FileExists($ShowDrive) Then FileInstall('ShowDrive.Vxd', $ShowDrive, 1)
_RunDOS($ShowDrive)

If Not FileExists($DosTool) Then FileInstall('DsptW.Vxd', $DosTool, 1)
_RunDOS($ComLine)

Local $diskinfo = FileOpen($IniFile, 0)
Local $TotalLine = 0

While 1
        FileReadLine($diskinfo, $TotalLine)
        If @error = -1 Then ExitLoop
        $TotalLine += 1
WEnd

Local $LineRead
$DiskList = ''
For $LineRead = 3 To $TotalLine - 2
        Local $LineForRead = FileReadLine($diskinfo, $LineRead)
        Local $InfoForRead = StringSplit($LineForRead, "        ")
        $te = StringSplit(StringStripWS($InfoForRead[1], 8), ":")
        $te2 = StringLeft(StringStripWS($InfoForRead[2], 8), 1)
        If $te2 = "A" Then
                $te4 = "活  动"
                if $ActivePar = '' then 
                    $ActivePar = $te[1] & ":"
                endif
        Else
                $te4 = "非活动"
        EndIf
        $mb = 1

        For $i = 4 To $InfoForRead[0]
                If Number($InfoForRead[$i]) > 1 Then
                        $q[$mb] = StringStripWS($InfoForRead[$i], 8)
                        $mb += 1
                EndIf
        Next
        $qq = $q[$mb - 2] + $q[$mb - 1]
        $w[$LineRead - 2] = $te[1] & ":" & "<" & DriveGetFileSystem($te[1] & ":") & ">   " & $te[2] & ":" & $te[3] & "   " & $te4 & "   " & $q[$mb - 2] & " Mb (总容量)"
        $DiskList = $DiskList & $w[$LineRead - 2] & '|'
Next

GUICtrlSetData($_disk1, $DiskList, $w[1])
GUICtrlSetData($_disk2, $DiskList, $w[1])
TrayTip("", "", 0)





While 1
        $nmsg = GUIGetMsg()
        Select

                Case $nmsg = $GUI_EVENT_CLOSE
                        _Quit()
                Case $nmsg = $_exit Or $nmsg = $_exit2
                        _Quit()
                Case $nmsg = $brow1
                        GUICtrlSetData($_wimimg, '', '')
                        $FilePath = FileOpenDialog("WIM文件选择", @ScriptDir, "WIM文件 (*.wim)", 1)
                        GUICtrlSetData($_wimfile1, $FilePath)
                        _FirstForm()
                Case $nmsg = $brow2
                        $wim2 = FileSaveDialog("输入WIM文件名", @ScriptDir, "WIM文件 (*.wim)", 2 + 16)
                        if StringRight($wim2,4) <>'.wim' then
                           $wim2 = $wim2 & '.wim'
                        endif
                        GUICtrlSetData($_wimfile2, $wim2)
                Case $nmsg = $_install
                        $TarPar = StringLeft(GUICtrlRead($_disk1), 2);取盘符号如C:
                        ;MsgBox(4096,"haha",$TarPar)
                        If GUICtrlRead($DiskRadio1) = 1 Then
                                $flag = MsgBox(1+48,"格式化 本地磁盘(" & $TarPar & ")","警告:格式化将删除该磁盘上的所有数据。" & @crlf & "若想格式化该磁盘请单击“确定”。若想退出,请单击“取消”")
                                if $flag = 1 then
                                    TrayTip("操作过程", "正在格式化磁盘", 3)
                                    _FormatIt()
                                endif
           
                        ElseIf GUICtrlRead($DiskRadio2) = 1 Then
                                _renOld()
                        EndIf
;                        _ImageX()
;                        _chksys()
                Case $nmsg = $_sysfix
                        _chksys()
                Case $nmsg = $_wimmak
                       $Parameter=' /compress max /capture '
;                       $ver = ''
                       _capture()
                Case $nmsg = $_wiadd
                       $Parameter=' /append '
;                       $ver = ' /verify'
                       _capture()



        EndSelect
WEnd

;提取镜像信息

Func _FirstForm()

        ;        MsgBox(4096,"haha",$FilePath)

        TrayTip("初始化程序中", "正在解压核心程序...", 3)
        FileInstall('imagex.exe', @TempDir & '\imagex.exe')
        TrayTip("初始化程序中", "正在提取镜像信息...", 3)
        RunWait('cmd /c ' & @TempDir & '\imagex.exe' & ' /info ' & $FilePath & ' >' & @TempDir & '\wim.txt', @ScriptDir, @SW_HIDE)
        _ReadWim(@TempDir & '\wim.txt')
        FileDelete(@TempDir & '\wim.txt')
        For $i = 1 To $FileNum
                TrayTip("初始化程序中", "正在提取卷信息...", 3)
                RunWait('cmd /c ' & @TempDir & '\imagex.exe' & ' /info ' & $FilePath & ' ' & $i & ' >' & @TempDir & '\wim' & $i & '.txt', @ScriptDir, @SW_HIDE)
                Dim $TXT = @TempDir & '\wim' & $i & '.txt'
                _ReadFullWim($TXT, $i)
                FileDelete($TXT)
        Next
        TrayTip("", "", 0)
        ;_InitialLevelForm()

EndFunc   ;==>_FirstForm

Func _ReadWim($GhostFname)
        Local $IniLineSum = 0 ; 每次读取一行文本,直到文件结束.

        Dim $EndNum, $FOne = 0, $CDriver, $DDriver, $result = ''
        Dim $TempNum = 1
        While 1
                $line = FileReadLine($GhostFname, $IniLineSum)
                If @error = -1 Then ExitLoop
                ;//-----------------卷号-------
                If StringLeft($line, 12) = "Image Count:" Then
                        $FileNum = StringRight($line, StringLen($line) - 13)
                EndIf
                If StringLeft(StringStripWS($line, 1), 6) = '<IMAGE' Then
                        $Image[$TempNum] = $IniLineSum
                        $result = $result & '  ' & @CRLF & $Image[$TempNum]
                        $TempNum += 1
                EndIf

                $IniLineSum += 1
        WEnd

        $EndNum = $IniLineSum - 1
        $Image[$TempNum] = $EndNum
        $IniLineSum = 0

        $result = ''


        For $i = 1 To $FileNum
                $x = $Image[$i]
                While $x < $Image[$i + 1]

                        $line = FileReadLine($GhostFname, $x)
                        If StringLeft(StringStripWS($line, 1), 6) = '<NAME>' Then
                                $LevelInfo[$i] = _XmlChange($line)
                        ElseIf StringLeft(StringStripWS($line, 1), 12) = '<DISPLAYNAME' Then
                                $LevelInfo[$i] = _XmlChange($line)
                        ElseIf StringLeft(StringStripWS($line, 1), 6) = '<BUILD' Then
                                $BUILD[$i] = _XmlChange($line)
                        ElseIf StringLeft(StringStripWS($line, 1), 8) = '<SPBUILD' Then
                                $SPBUILD[$i] = _XmlChange($line)
                        ElseIf StringLeft(StringStripWS($line, 1), 10) = '<LANGUAGE>' Then
                                $Langue[$i] = _XmlChange($line)
                        ElseIf StringLeft(StringStripWS($line, 1), 13) = '<DESCRIPTION>' Then
                                $FullInfo[$i] = _XmlChange($line)
                        ElseIf StringLeft(StringStripWS($line, 1), 9) = '<DISPLAYD' Then
                                $FullInfo[$i] = _XmlChange($line)
                        EndIf

                        $x += 1
                WEnd
                ;MsgBox(4096,"FullInfo=", $FullInfo[$i])
                $imgvol[$i] = $i & ':  ' & $LevelInfo[$i]
                $LevelInfo[$i] = ''
                $FullInfo[$i] = ''
                ;                        $result=$result&$imgvol[$i]&'|'
        Next
        $result = _ArrayToString($imgvol, '|', 1, $FileNum) ;把一个数组的内容到一个单一的字符串,分隔指定定界符
        GUICtrlSetData($_wimimg, $result, $imgvol[1])

EndFunc   ;==>_ReadWim

Func _ReadFullWim($GhostFname, $i)
        Dim $FileNum, $EndNum, $IniLineSum = 1, $FullInfo
        While 1
                $line = FileReadLine($GhostFname, $IniLineSum)
                If @error Then ExitLoop

                If StringLeft(StringStripWS($line, 1), 9) = '<DISPLAYD' Then
                        $FullInfo[$i] = _XmlChange($line)
                        ExitLoop
                EndIf
                $IniLineSum += 1
        WEnd
EndFunc   ;==>_ReadFullWim


Func _XmlChange($TxtInfo)
        Dim $PreRead = StringSplit(StringStripWS($TxtInfo, 1), "<")
        Dim $NextRead = StringSplit($PreRead[2], ">")
        Return $NextRead[2]
EndFunc   ;==>_XmlChange


Func _FormatIt()
        TrayTip("操作过程", "正在格式化磁盘", 3)
        FileInstall('format.COM', @TempDir & '\format.COM', 1)
        RunWait("cmd /c " & @TempDir & "\format /fs:ntfs /q /y " & $TarPar & '')
        TrayTip("", "", 0)
        FileDelete(@TempDir & '\format.COM')
                        _ImageX()
                        _chksys()
EndFunc   ;==>_FormatIt

Func _renOld()
        FileSetAttrib($TarPar & '\ProgramData', "-RSH")
        FileSetAttrib($TarPar & '\Documents and Settings', "-RSH")
        Local $search = FileFindFirstFile($TarPar & "\*.*"), $result1 = ''
        While 1
                Dim $file = FileFindNextFile($search)
                If @error Then ExitLoop
                If $result1 = '' Then
                        $result1 = 'ren "' & $TarPar & '\' & $file & '" "' & $file & '.old"'
                Else
                        $result1 = $result1 & ' & ren "' & $TarPar & '\' & $file & '" "' & $file & '.old"'
                EndIf
        WEnd
        RunWait("cmd /c " & $result1 & '', '', @SW_HIDE)
                        _ImageX()
                        _chksys()
EndFunc   ;==>_renOld

Func _ImageX()
        Local $foo, $line, $lines, $currentRead
        ;                GUICtrlSetState($ProButton2,$gui_enable)

        $Progress1 = GUICtrlCreateProgress(21, 224, 297, 15)

        $LevelMode = StringSplit(GUICtrlRead($_wimimg), ':')
        $TarPar = StringLeft(GUICtrlRead($_disk1), 2)
        $foo = Run('cmd /c ' & @TempDir & '\imagex.exe' & ' /apply ' & $FilePath & ' ' & $LevelMode[1] & ' ' & $TarPar & ' ', @ScriptDir, @SW_HIDE, $STDOUT_CHILD)
        While 1
                $line = StdoutRead($foo)
                If @error Then ExitLoop
                $msg = GUIGetMsg()

                GUICtrlSetData($Progress1, $line, -1)
                Dim $Progress, $ProgressA, $ProgressB, $RemainTime = '', $RemainTimeA, $RemainTimeB, $RemainTimeC
                If StringStripWS($line, 8) <> "" Then
                        Dim $TxtRead = StringStripCR($line)
                        If StringInStr($TxtRead, "Applying progress") Then
                                $ProgressA = StringSplit($TxtRead, "]")
                                $ProgressB = StringSplit($ProgressA[1], "[")
                                $Progress = StringStripCR(StringStripWS($ProgressB[2], 8))
                        EndIf
                        GUICtrlSetData($Progress1, StringTrimRight($Progress, 1))
                        GUICtrlSetData($Label4, "文件解压进度: " & $Progress)
                        If StringInStr($TxtRead, "remaining") Then
                                $RemainTimeA = StringSplit(StringLeft($TxtRead, StringLen($TxtRead) - 10), "o")
                                $RemainTimeB = StringRight($RemainTimeA[2], StringLen($RemainTimeA[2]) - 7)
                                If StringInStr($RemainTimeB, "mins") Then
                                        $RemainTimeC = StringSplit($RemainTimeB, ":")
                                        $RemainTime = "剩余时间: " & $RemainTimeC[1] & " 分 " & StringLeft($RemainTimeC[2], 2) & " 秒 "
                                ElseIf StringInStr($RemainTimeB, "sec") Then
                                        $RemainTime = StringLeft(StringStripCR(StringStripWS($RemainTimeB, 8)), 2)
                                        If StringRight($RemainTime, 1) = "s" Then $RemainTime = StringLeft($RemainTime, 1)
                                        $RemainTime = "剩余时间: " & $RemainTime & " 秒 "
                                EndIf
                        EndIf
                        If $RemainTime <> '' Then

                                GUICtrlSetData($Label5, $RemainTime)
                        EndIf
                        If StringInStr($TxtRead, "Successfully") Then
                                GUICtrlSetData($Label5, "")
                                GUICtrlSetData($Label4, "文件解压进度: 完成  ")
                                GUICtrlSetState($Progress1, $GUI_HIDE)        
                EndIf
                EndIf

        WEnd

EndFunc   ;==>_ImageX

Func _chksys()
;        MsgBox(4096,"run=", '_chksys()')
        $TarPar = StringLeft(GUICtrlRead($_disk1), 2)
        TrayTip("操作过程", "正在修复引导", 2)
        If FileExists($TarPar & "\windows\system32\slmgr.vbs ") Then
                _FixBoot()
                TrayTip("操作过程", "正在修复系统位置", 2)
                _FixLetter()
;                TrayTip("操作过程", "正在更改系统盘符", 2)
                _ChangeLetter()
                If $BootRes = $FixRes = 1 Then
;                        GUISetState(@SW_HIDE)
                        TrayTip("操作结束", "系统文件复制成功,现在可以重启", 3)
                        DirRemove(@TempDir & "\win7", 1)
;                        Sleep(3000)
;                        Exit
                EndIf
                DirRemove(@TempDir & "\win7", 1)
;                TrayTip("", "", 0)
        Else
                _FixBoot_xp()
        EndIf
EndFunc   ;==>_chksys

Func _FixBoot_xp()
;        MsgBox(4096,"run=",  '_FixBoot_xp()')
;        _DirInstall(@ScriptDir & '\xp')
        FileInstall('NTDETECT.COM', @TempDir & '\NTDETECT.COM', 1)
        FileInstall('attrib.exe', @TempDir & '\attrib.exe', 1)
        FileInstall('boot.ini', @TempDir & '\boot.ini', 1)
        FileInstall('bootfont.bin', @TempDir & '\bootfont.bin', 1)
        FileInstall('ntldr', @TempDir & '\ntldr', 1)
        FileInstall('fixboot_xp.cmd', @TempDir & '\fixboot_xp.cmd', 1)
        FileInstall('bootsect.exe', @TempDir & '\bootsect.exe', 1)
        sleep(5000)
        RunWait("cmd /c " & @TempDir & '\fixboot_xp.cmd' & ' ' & $TarPar & ' ' & @TempDir, @ScriptDir, @SW_HIDE, $STDOUT_CHILD)
        GUICtrlSetData($Label6, "引导文件修复: 完成,重启")
        ;         GUICtrlSetState ($Label6,$GUI_SHOW)
        TrayTip("", "", 0)
;        DirRemove(@TempDir & "\xp", 1)
        FileDelete(@TempDir & '\attrib.exe')
        FileDelete(@TempDir & '\boot.ini')
        FileDelete(@TempDir & '\bootfont.bin')
        FileDelete(@TempDir & '\ntldr')
        FileDelete(@TempDir & '\fixboot_xp.cmd')
        FileDelete(@TempDir & '\bootsect.exe')
        FileDelete(@TempDir & '\NTDETECT.COM')
EndFunc   ;==>_FixBoot_xp

Func _FixBoot()
;       MsgBox(4096,"run=",  '_FixBoot()')
        Local $foo3, $line, $lines, $currentRead
;        _DirInstall(@ScriptDir & '\win7')
        FileInstall('bcdboot.exe', @TempDir & '\bcdboot.exe')

        $foo3 = Run("cmd /c " & @TempDir & '\bcdboot.exe' & ' ' & $TarPar & '\windows /s ' & $ActivePar, @ScriptDir, @SW_HIDE, $STDOUT_CHILD)
        While 1
                $line = StdoutRead($foo3)
                If @error Then ExitLoop

;         $msg = GUIGetMsg()

                GUICtrlSetData($ProgressEdit, $line, -1)
                If StringStripWS($line, 8) <> "" Then
                        Dim $TxtRead = StringStripCR($line)
                        If StringInStr($TxtRead, "Failure") Then
                                GUICtrlSetData($Label6, "引导文件修复: 失败")
                                $BootRes = 2
                        ElseIf StringInStr($TxtRead, "successfully") Then
                                GUICtrlSetData($Label6, "引导文件修复: 成功")
                                $BootRes = 1
                        EndIf
                EndIf
        WEnd
        If $BootRes = 0 Then GUICtrlSetData($Label6, "引导文件修复: 失败")
                FileDelete(@TempDir & '\bcdboot.exe')
EndFunc   ;==>_FixBoot


Func _FixLetter()
        Local $foo1, $line, $lines, $currentRead
        FileInstall('fixletter.cmd', @TempDir & '\fixletter.cmd')
        $foo1 = Run("cmd /c " & @TempDir & '\fixletter.cmd' & ' /currentos:' & $TarPar & ' & pause', @ScriptDir, @SW_HIDE, $STDOUT_CHILD)
        While 1
                $line = StdoutRead($foo1)
                If @error Then ExitLoop

;                $msg = GUIGetMsg()
                GUICtrlSetData($Progress1, $line, -1)
                If StringStripWS($line, 8) <> "" Then
                        Dim $TxtRead = StringStripCR($line)
                        If StringInStr($TxtRead, "Failure") Then
                                GUICtrlSetData($Label7, "系统文件修正: 失败")
                                $FixRes = 2
                        ElseIf StringInStr($TxtRead, "Script completed") Then
                                GUICtrlSetData($Label7, "系统文件修正: 成功")
                                $FixRes = 1
                        EndIf
                EndIf
        WEnd

        If $FixRes = 0 Then GUICtrlSetData($Label7, "系统文件修正: 失败")
        FileDelete(@TempDir & '\fixletter.cmd')
EndFunc   ;==>_FixLetter


Func _ChangeLetter()
        Local $foo2, $line, $lines, $currentRead
        FileInstall('osletter7.cmd', @TempDir & '\osletter7.cmd')
        $foo2 = Run("cmd /c " & @TempDir & '\osletter7.cmd' & ' /targetletter:' & $TarPar & ' /currentos:' & $ActivePar & ' ', @ScriptDir, @SW_HIDE, $STDOUT_CHILD)
        While 1
                $line = StdoutRead($foo2)
                If @error Then ExitLoop

;                $msg = GUIGetMsg()
                GUICtrlSetData($Progress1, $line, -1)
                If StringStripWS($line, 8) <> "" Then
                        Dim $TxtRead = StringStripCR($line)
                        If StringInStr($TxtRead, "Failure") Then
                                GUICtrlSetData($Label8, "系统盘符修正: 失败")
                                $ChangeRes = 2
                        ElseIf StringInStr($TxtRead, "Script completed") Then
                                GUICtrlSetData($Label8, "系统盘符修正: 成功")
                                $ChangeRes = 1
                        EndIf
                EndIf
        WEnd
        If $ChangeRes = 0 Then GUICtrlSetData($Label8, "系统盘符修正:无需修正")
        FileDelete(@TempDir & '\osletter7.cmd')
        FileInstall('bootsect.exe', @TempDir & '\bootsect.exe', 1)
        RunWait('cmd /c ' & @TempDir & '\bootsect.exe /nt60 sys', @SW_HIDE)
        RunWait('cmd /c ' & @TempDir & '\bootsect.exe /nt60 ' & $ActivePar & ' ', "", @SW_HIDE)
        FileDelete(@TempDir & '\bootsect.exe')
EndFunc   ;==>_ChangeLetter

Func _capture()
        Local $foo, $line, $lines, $currentRead
        FileInstall('imagex.exe', @TempDir & '\imagex.exe')
                $Progress2 = GUICtrlCreateProgress(21, 224, 297, 15)

;         $LevelMode=StringLeft(GUICtrlRead($_wimimg), 1)
        $TarPar=StringLeft(GUICtrlRead($_disk2), 2)
        $wimvol=GUICtrlRead($_wimvol)
; MsgBox(4096,"run=",  'cmd /c ' & @TempDir & '\imagex.exe' & $Parameter & $TarPar & ' ' & $wim2  & ' ' & '"' & $wimvol & '"' & $ver)
        $foo = Run('cmd /c ' & @TempDir & '\imagex.exe' & $Parameter & $TarPar & ' ' & $wim2  & ' ' & '"' & $wimvol & '"', @ScriptDir, @SW_HIDE, $STDOUT_CHILD)
        While 1
                $line = StdoutRead($foo)
                If @error Then ExitLoop
                $msg = GUIGetMsg()

                GUICtrlSetData($Progress2, $line, -1)
                Dim $Progress, $ProgressA, $ProgressB, $RemainTime = '', $RemainTimeA, $RemainTimeB, $RemainTimeC
                If StringStripWS($line, 8) <> "" Then
                        Dim $TxtRead = StringStripCR($line)
                        If StringInStr($TxtRead, "Appending ") or StringInStr($TxtRead, "Capturing progress") Then
                                $ProgressA = StringSplit($TxtRead, "]")
                                $ProgressB = StringSplit($ProgressA[1], "[")
                                $Progress = StringStripCR(StringStripWS($ProgressB[2], 8))
                        EndIf
                        GUICtrlSetData($Progress2, StringTrimRight($Progress, 1))
                        GUICtrlSetData($Label12, "文件压制进度: " & $Progress)
                        If StringInStr($TxtRead, "remaining") Then
                                $RemainTimeA = StringSplit(StringLeft($TxtRead, StringLen($TxtRead) - 10), "o")
                                $RemainTimeB = StringRight($RemainTimeA[2], StringLen($RemainTimeA[2]) - 7)
                                If StringInStr($RemainTimeB, "mins") Then
                                        $RemainTimeC = StringSplit($RemainTimeB, ":")
                                        $RemainTime = "剩余时间: " & $RemainTimeC[1] & " 分 " & StringLeft($RemainTimeC[2], 2) & " 秒 "
                                ElseIf StringInStr($RemainTimeB, "sec") Then
                                        $RemainTime = StringLeft(StringStripCR(StringStripWS($RemainTimeB, 8)), 2)
                                        If StringRight($RemainTime, 1) = "s" Then $RemainTime = StringLeft($RemainTime, 1)
                                        $RemainTime = "剩余时间: " & $RemainTime & " 秒 "
                                EndIf
                        EndIf
                        If $RemainTime <> '' Then

                                GUICtrlSetData($Label16, $RemainTime)
                        EndIf
                        If StringInStr($TxtRead, "Successfully") Then
                                GUICtrlSetData($Label16, "")
                                GUICtrlSetData($Label12, "文件压制进度: 完成  ")
                                GUICtrlSetState($Progress2, $GUI_HIDE)
                        EndIf
                EndIf

        WEnd

EndFunc   ;==>_capture


Func _Quit()
        FileDelete(@TempDir & '\wim.txt')
        FileDelete($IniFile)
        FileDelete(@TempDir & '\ShowDrive.eXe')
        FileDelete(@TempDir & '\DsptW.eXe')
        FileDelete(@TempDir & '\imagex.exe')
        ;        DirRemove(@TempDir & "\xp", 1)

        Exit
EndFunc   ;==>_Quit
回复 25# 苹果控
发表于 2015-3-7 12:50:05 | 显示全部楼层
没金币了阿2
发表于 2015-11-2 16:21:44 | 显示全部楼层
下载不了?
发表于 2016-5-18 23:57:24 | 显示全部楼层
做一键恢复还是比较有用的
发表于 2022-7-15 22:10:22 | 显示全部楼层
一直用的是 WimTool
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-29 14:32 , Processed in 0.079812 second(s), 15 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表