找回密码
 加入
搜索
楼主: 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 | 显示全部楼层
  1. #Region ;**** 参数创建于 ACNWrapper_GUI ****
  2. #AutoIt3Wrapper_icon=ico.ico
  3. #AutoIt3Wrapper_outfile=Z:\C\tools\wim\bbzwim.exe
  4. #AutoIt3Wrapper_Res_Comment=笨笨朱制作
  5. #AutoIt3Wrapper_Res_Description=系统镜像安装制作  笨笨朱
  6. #AutoIt3Wrapper_Res_Fileversion=1.0.0.0
  7. #EndRegion ;**** 参数创建于 ACNWrapper_GUI ****

  8. #include <ComboConstants.au3>
  9. #include <TabConstants.au3>
  10. #include <ButtonConstants.au3>
  11. #include <GUIConstantsEx.au3>
  12. #include <WindowsConstants.au3>
  13. #include <GUIComboBox.au3>
  14. #include <GuiConstantsEx.au3>
  15. #include <Constants.au3>
  16. #include <GUIListBox.au3>
  17. #include <GuiConstantsEx.au3>
  18. #include <GuiListView.au3>
  19. #include <Process.Au3>
  20. #include <StaticConstants.au3>
  21. #include <EditConstants.au3>
  22. #include <Constants.au3>
  23. #include <StaticConstants.au3>
  24. #include <ProgressConstants.au3>
  25. ;#include "DirInstall_udf.au3"
  26. #include <GUIConstantsEx.au3>


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


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

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

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

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

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

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

  93. Local $diskinfo = FileOpen($IniFile, 0)
  94. Local $TotalLine = 0

  95. While 1
  96.         FileReadLine($diskinfo, $TotalLine)
  97.         If @error = -1 Then ExitLoop
  98.         $TotalLine += 1
  99. WEnd

  100. Local $LineRead
  101. $DiskList = ''
  102. For $LineRead = 3 To $TotalLine - 2
  103.         Local $LineForRead = FileReadLine($diskinfo, $LineRead)
  104.         Local $InfoForRead = StringSplit($LineForRead, "        ")
  105.         $te = StringSplit(StringStripWS($InfoForRead[1], 8), ":")
  106.         $te2 = StringLeft(StringStripWS($InfoForRead[2], 8), 1)
  107.         If $te2 = "A" Then
  108.                 $te4 = "活  动"
  109.                 if $ActivePar = '' then
  110.                     $ActivePar = $te[1] & ":"
  111.                 endif
  112.         Else
  113.                 $te4 = "非活动"
  114.         EndIf
  115.         $mb = 1

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

  126. GUICtrlSetData($_disk1, $DiskList, $w[1])
  127. GUICtrlSetData($_disk2, $DiskList, $w[1])
  128. TrayTip("", "", 0)





  129. While 1
  130.         $nmsg = GUIGetMsg()
  131.         Select

  132.                 Case $nmsg = $GUI_EVENT_CLOSE
  133.                         _Quit()
  134.                 Case $nmsg = $_exit Or $nmsg = $_exit2
  135.                         _Quit()
  136.                 Case $nmsg = $brow1
  137.                         GUICtrlSetData($_wimimg, '', '')
  138.                         $FilePath = FileOpenDialog("WIM文件选择", @ScriptDir, "WIM文件 (*.wim)", 1)
  139.                         GUICtrlSetData($_wimfile1, $FilePath)
  140.                         _FirstForm()
  141.                 Case $nmsg = $brow2
  142.                         $wim2 = FileSaveDialog("输入WIM文件名", @ScriptDir, "WIM文件 (*.wim)", 2 + 16)
  143.                         if StringRight($wim2,4) <>'.wim' then
  144.                            $wim2 = $wim2 & '.wim'
  145.                         endif
  146.                         GUICtrlSetData($_wimfile2, $wim2)
  147.                 Case $nmsg = $_install
  148.                         $TarPar = StringLeft(GUICtrlRead($_disk1), 2);取盘符号如C:
  149.                         ;MsgBox(4096,"haha",$TarPar)
  150.                         If GUICtrlRead($DiskRadio1) = 1 Then
  151.                                 $flag = MsgBox(1+48,"格式化 本地磁盘(" & $TarPar & ")","警告:格式化将删除该磁盘上的所有数据。" & @crlf & "若想格式化该磁盘请单击“确定”。若想退出,请单击“取消”")
  152.                                 if $flag = 1 then
  153.                                     TrayTip("操作过程", "正在格式化磁盘", 3)
  154.                                     _FormatIt()
  155.                                 endif
  156.            
  157.                         ElseIf GUICtrlRead($DiskRadio2) = 1 Then
  158.                                 _renOld()
  159.                         EndIf
  160. ;                        _ImageX()
  161. ;                        _chksys()
  162.                 Case $nmsg = $_sysfix
  163.                         _chksys()
  164.                 Case $nmsg = $_wimmak
  165.                        $Parameter=' /compress max /capture '
  166. ;                       $ver = ''
  167.                        _capture()
  168.                 Case $nmsg = $_wiadd
  169.                        $Parameter=' /append '
  170. ;                       $ver = ' /verify'
  171.                        _capture()



  172.         EndSelect
  173. WEnd

  174. ;提取镜像信息

  175. Func _FirstForm()

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

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

  192. EndFunc   ;==>_FirstForm

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

  195.         Dim $EndNum, $FOne = 0, $CDriver, $DDriver, $result = ''
  196.         Dim $TempNum = 1
  197.         While 1
  198.                 $line = FileReadLine($GhostFname, $IniLineSum)
  199.                 If @error = -1 Then ExitLoop
  200.                 ;//-----------------卷号-------
  201.                 If StringLeft($line, 12) = "Image Count:" Then
  202.                         $FileNum = StringRight($line, StringLen($line) - 13)
  203.                 EndIf
  204.                 If StringLeft(StringStripWS($line, 1), 6) = '<IMAGE' Then
  205.                         $Image[$TempNum] = $IniLineSum
  206.                         $result = $result & '  ' & @CRLF & $Image[$TempNum]
  207.                         $TempNum += 1
  208.                 EndIf

  209.                 $IniLineSum += 1
  210.         WEnd

  211.         $EndNum = $IniLineSum - 1
  212.         $Image[$TempNum] = $EndNum
  213.         $IniLineSum = 0

  214.         $result = ''


  215.         For $i = 1 To $FileNum
  216.                 $x = $Image[$i]
  217.                 While $x < $Image[$i + 1]

  218.                         $line = FileReadLine($GhostFname, $x)
  219.                         If StringLeft(StringStripWS($line, 1), 6) = '<NAME>' Then
  220.                                 $LevelInfo[$i] = _XmlChange($line)
  221.                         ElseIf StringLeft(StringStripWS($line, 1), 12) = '<DISPLAYNAME' Then
  222.                                 $LevelInfo[$i] = _XmlChange($line)
  223.                         ElseIf StringLeft(StringStripWS($line, 1), 6) = '<BUILD' Then
  224.                                 $BUILD[$i] = _XmlChange($line)
  225.                         ElseIf StringLeft(StringStripWS($line, 1), 8) = '<SPBUILD' Then
  226.                                 $SPBUILD[$i] = _XmlChange($line)
  227.                         ElseIf StringLeft(StringStripWS($line, 1), 10) = '<LANGUAGE>' Then
  228.                                 $Langue[$i] = _XmlChange($line)
  229.                         ElseIf StringLeft(StringStripWS($line, 1), 13) = '<DESCRIPTION>' Then
  230.                                 $FullInfo[$i] = _XmlChange($line)
  231.                         ElseIf StringLeft(StringStripWS($line, 1), 9) = '<DISPLAYD' Then
  232.                                 $FullInfo[$i] = _XmlChange($line)
  233.                         EndIf

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

  244. EndFunc   ;==>_ReadWim

  245. Func _ReadFullWim($GhostFname, $i)
  246.         Dim $FileNum, $EndNum, $IniLineSum = 1, $FullInfo
  247.         While 1
  248.                 $line = FileReadLine($GhostFname, $IniLineSum)
  249.                 If @error Then ExitLoop

  250.                 If StringLeft(StringStripWS($line, 1), 9) = '<DISPLAYD' Then
  251.                         $FullInfo[$i] = _XmlChange($line)
  252.                         ExitLoop
  253.                 EndIf
  254.                 $IniLineSum += 1
  255.         WEnd
  256. EndFunc   ;==>_ReadFullWim


  257. Func _XmlChange($TxtInfo)
  258.         Dim $PreRead = StringSplit(StringStripWS($TxtInfo, 1), "<")
  259.         Dim $NextRead = StringSplit($PreRead[2], ">")
  260.         Return $NextRead[2]
  261. EndFunc   ;==>_XmlChange


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

  271. Func _renOld()
  272.         FileSetAttrib($TarPar & '\ProgramData', "-RSH")
  273.         FileSetAttrib($TarPar & '\Documents and Settings', "-RSH")
  274.         Local $search = FileFindFirstFile($TarPar & "\*.*"), $result1 = ''
  275.         While 1
  276.                 Dim $file = FileFindNextFile($search)
  277.                 If @error Then ExitLoop
  278.                 If $result1 = '' Then
  279.                         $result1 = 'ren "' & $TarPar & '\' & $file & '" "' & $file & '.old"'
  280.                 Else
  281.                         $result1 = $result1 & ' & ren "' & $TarPar & '\' & $file & '" "' & $file & '.old"'
  282.                 EndIf
  283.         WEnd
  284.         RunWait("cmd /c " & $result1 & '', '', @SW_HIDE)
  285.                         _ImageX()
  286.                         _chksys()
  287. EndFunc   ;==>_renOld

  288. Func _ImageX()
  289.         Local $foo, $line, $lines, $currentRead
  290.         ;                GUICtrlSetState($ProButton2,$gui_enable)

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

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

  299.                 GUICtrlSetData($Progress1, $line, -1)
  300.                 Dim $Progress, $ProgressA, $ProgressB, $RemainTime = '', $RemainTimeA, $RemainTimeB, $RemainTimeC
  301.                 If StringStripWS($line, 8) <> "" Then
  302.                         Dim $TxtRead = StringStripCR($line)
  303.                         If StringInStr($TxtRead, "Applying progress") Then
  304.                                 $ProgressA = StringSplit($TxtRead, "]")
  305.                                 $ProgressB = StringSplit($ProgressA[1], "[")
  306.                                 $Progress = StringStripCR(StringStripWS($ProgressB[2], 8))
  307.                         EndIf
  308.                         GUICtrlSetData($Progress1, StringTrimRight($Progress, 1))
  309.                         GUICtrlSetData($Label4, "文件解压进度: " & $Progress)
  310.                         If StringInStr($TxtRead, "remaining") Then
  311.                                 $RemainTimeA = StringSplit(StringLeft($TxtRead, StringLen($TxtRead) - 10), "o")
  312.                                 $RemainTimeB = StringRight($RemainTimeA[2], StringLen($RemainTimeA[2]) - 7)
  313.                                 If StringInStr($RemainTimeB, "mins") Then
  314.                                         $RemainTimeC = StringSplit($RemainTimeB, ":")
  315.                                         $RemainTime = "剩余时间: " & $RemainTimeC[1] & " 分 " & StringLeft($RemainTimeC[2], 2) & " 秒 "
  316.                                 ElseIf StringInStr($RemainTimeB, "sec") Then
  317.                                         $RemainTime = StringLeft(StringStripCR(StringStripWS($RemainTimeB, 8)), 2)
  318.                                         If StringRight($RemainTime, 1) = "s" Then $RemainTime = StringLeft($RemainTime, 1)
  319.                                         $RemainTime = "剩余时间: " & $RemainTime & " 秒 "
  320.                                 EndIf
  321.                         EndIf
  322.                         If $RemainTime <> '' Then

  323.                                 GUICtrlSetData($Label5, $RemainTime)
  324.                         EndIf
  325.                         If StringInStr($TxtRead, "Successfully") Then
  326.                                 GUICtrlSetData($Label5, "")
  327.                                 GUICtrlSetData($Label4, "文件解压进度: 完成  ")
  328.                                 GUICtrlSetState($Progress1, $GUI_HIDE)       
  329.                 EndIf
  330.                 EndIf

  331.         WEnd

  332. EndFunc   ;==>_ImageX

  333. Func _chksys()
  334. ;        MsgBox(4096,"run=", '_chksys()')
  335.         $TarPar = StringLeft(GUICtrlRead($_disk1), 2)
  336.         TrayTip("操作过程", "正在修复引导", 2)
  337.         If FileExists($TarPar & "\windows\system32\slmgr.vbs ") Then
  338.                 _FixBoot()
  339.                 TrayTip("操作过程", "正在修复系统位置", 2)
  340.                 _FixLetter()
  341. ;                TrayTip("操作过程", "正在更改系统盘符", 2)
  342.                 _ChangeLetter()
  343.                 If $BootRes = $FixRes = 1 Then
  344. ;                        GUISetState(@SW_HIDE)
  345.                         TrayTip("操作结束", "系统文件复制成功,现在可以重启", 3)
  346.                         DirRemove(@TempDir & "\win7", 1)
  347. ;                        Sleep(3000)
  348. ;                        Exit
  349.                 EndIf
  350.                 DirRemove(@TempDir & "\win7", 1)
  351. ;                TrayTip("", "", 0)
  352.         Else
  353.                 _FixBoot_xp()
  354.         EndIf
  355. EndFunc   ;==>_chksys

  356. Func _FixBoot_xp()
  357. ;        MsgBox(4096,"run=",  '_FixBoot_xp()')
  358. ;        _DirInstall(@ScriptDir & '\xp')
  359.         FileInstall('NTDETECT.COM', @TempDir & '\NTDETECT.COM', 1)
  360.         FileInstall('attrib.exe', @TempDir & '\attrib.exe', 1)
  361.         FileInstall('boot.ini', @TempDir & '\boot.ini', 1)
  362.         FileInstall('bootfont.bin', @TempDir & '\bootfont.bin', 1)
  363.         FileInstall('ntldr', @TempDir & '\ntldr', 1)
  364.         FileInstall('fixboot_xp.cmd', @TempDir & '\fixboot_xp.cmd', 1)
  365.         FileInstall('bootsect.exe', @TempDir & '\bootsect.exe', 1)
  366.         sleep(5000)
  367.         RunWait("cmd /c " & @TempDir & '\fixboot_xp.cmd' & ' ' & $TarPar & ' ' & @TempDir, @ScriptDir, @SW_HIDE, $STDOUT_CHILD)
  368.         GUICtrlSetData($Label6, "引导文件修复: 完成,重启")
  369.         ;         GUICtrlSetState ($Label6,$GUI_SHOW)
  370.         TrayTip("", "", 0)
  371. ;        DirRemove(@TempDir & "\xp", 1)
  372.         FileDelete(@TempDir & '\attrib.exe')
  373.         FileDelete(@TempDir & '\boot.ini')
  374.         FileDelete(@TempDir & '\bootfont.bin')
  375.         FileDelete(@TempDir & '\ntldr')
  376.         FileDelete(@TempDir & '\fixboot_xp.cmd')
  377.         FileDelete(@TempDir & '\bootsect.exe')
  378.         FileDelete(@TempDir & '\NTDETECT.COM')
  379. EndFunc   ;==>_FixBoot_xp

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

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

  389. ;         $msg = GUIGetMsg()

  390.                 GUICtrlSetData($ProgressEdit, $line, -1)
  391.                 If StringStripWS($line, 8) <> "" Then
  392.                         Dim $TxtRead = StringStripCR($line)
  393.                         If StringInStr($TxtRead, "Failure") Then
  394.                                 GUICtrlSetData($Label6, "引导文件修复: 失败")
  395.                                 $BootRes = 2
  396.                         ElseIf StringInStr($TxtRead, "successfully") Then
  397.                                 GUICtrlSetData($Label6, "引导文件修复: 成功")
  398.                                 $BootRes = 1
  399.                         EndIf
  400.                 EndIf
  401.         WEnd
  402.         If $BootRes = 0 Then GUICtrlSetData($Label6, "引导文件修复: 失败")
  403.                 FileDelete(@TempDir & '\bcdboot.exe')
  404. EndFunc   ;==>_FixBoot


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

  412. ;                $msg = GUIGetMsg()
  413.                 GUICtrlSetData($Progress1, $line, -1)
  414.                 If StringStripWS($line, 8) <> "" Then
  415.                         Dim $TxtRead = StringStripCR($line)
  416.                         If StringInStr($TxtRead, "Failure") Then
  417.                                 GUICtrlSetData($Label7, "系统文件修正: 失败")
  418.                                 $FixRes = 2
  419.                         ElseIf StringInStr($TxtRead, "Script completed") Then
  420.                                 GUICtrlSetData($Label7, "系统文件修正: 成功")
  421.                                 $FixRes = 1
  422.                         EndIf
  423.                 EndIf
  424.         WEnd

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


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

  435. ;                $msg = GUIGetMsg()
  436.                 GUICtrlSetData($Progress1, $line, -1)
  437.                 If StringStripWS($line, 8) <> "" Then
  438.                         Dim $TxtRead = StringStripCR($line)
  439.                         If StringInStr($TxtRead, "Failure") Then
  440.                                 GUICtrlSetData($Label8, "系统盘符修正: 失败")
  441.                                 $ChangeRes = 2
  442.                         ElseIf StringInStr($TxtRead, "Script completed") Then
  443.                                 GUICtrlSetData($Label8, "系统盘符修正: 成功")
  444.                                 $ChangeRes = 1
  445.                         EndIf
  446.                 EndIf
  447.         WEnd
  448.         If $ChangeRes = 0 Then GUICtrlSetData($Label8, "系统盘符修正:无需修正")
  449.         FileDelete(@TempDir & '\osletter7.cmd')
  450.         FileInstall('bootsect.exe', @TempDir & '\bootsect.exe', 1)
  451.         RunWait('cmd /c ' & @TempDir & '\bootsect.exe /nt60 sys', @SW_HIDE)
  452.         RunWait('cmd /c ' & @TempDir & '\bootsect.exe /nt60 ' & $ActivePar & ' ', "", @SW_HIDE)
  453.         FileDelete(@TempDir & '\bootsect.exe')
  454. EndFunc   ;==>_ChangeLetter

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

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

  468.                 GUICtrlSetData($Progress2, $line, -1)
  469.                 Dim $Progress, $ProgressA, $ProgressB, $RemainTime = '', $RemainTimeA, $RemainTimeB, $RemainTimeC
  470.                 If StringStripWS($line, 8) <> "" Then
  471.                         Dim $TxtRead = StringStripCR($line)
  472.                         If StringInStr($TxtRead, "Appending ") or StringInStr($TxtRead, "Capturing progress") Then
  473.                                 $ProgressA = StringSplit($TxtRead, "]")
  474.                                 $ProgressB = StringSplit($ProgressA[1], "[")
  475.                                 $Progress = StringStripCR(StringStripWS($ProgressB[2], 8))
  476.                         EndIf
  477.                         GUICtrlSetData($Progress2, StringTrimRight($Progress, 1))
  478.                         GUICtrlSetData($Label12, "文件压制进度: " & $Progress)
  479.                         If StringInStr($TxtRead, "remaining") Then
  480.                                 $RemainTimeA = StringSplit(StringLeft($TxtRead, StringLen($TxtRead) - 10), "o")
  481.                                 $RemainTimeB = StringRight($RemainTimeA[2], StringLen($RemainTimeA[2]) - 7)
  482.                                 If StringInStr($RemainTimeB, "mins") Then
  483.                                         $RemainTimeC = StringSplit($RemainTimeB, ":")
  484.                                         $RemainTime = "剩余时间: " & $RemainTimeC[1] & " 分 " & StringLeft($RemainTimeC[2], 2) & " 秒 "
  485.                                 ElseIf StringInStr($RemainTimeB, "sec") Then
  486.                                         $RemainTime = StringLeft(StringStripCR(StringStripWS($RemainTimeB, 8)), 2)
  487.                                         If StringRight($RemainTime, 1) = "s" Then $RemainTime = StringLeft($RemainTime, 1)
  488.                                         $RemainTime = "剩余时间: " & $RemainTime & " 秒 "
  489.                                 EndIf
  490.                         EndIf
  491.                         If $RemainTime <> '' Then

  492.                                 GUICtrlSetData($Label16, $RemainTime)
  493.                         EndIf
  494.                         If StringInStr($TxtRead, "Successfully") Then
  495.                                 GUICtrlSetData($Label16, "")
  496.                                 GUICtrlSetData($Label12, "文件压制进度: 完成  ")
  497.                                 GUICtrlSetState($Progress2, $GUI_HIDE)
  498.                         EndIf
  499.                 EndIf

  500.         WEnd

  501. EndFunc   ;==>_capture


  502. Func _Quit()
  503.         FileDelete(@TempDir & '\wim.txt')
  504.         FileDelete($IniFile)
  505.         FileDelete(@TempDir & '\ShowDrive.eXe')
  506.         FileDelete(@TempDir & '\DsptW.eXe')
  507.         FileDelete(@TempDir & '\imagex.exe')
  508.         ;        DirRemove(@TempDir & "\xp", 1)

  509.         Exit
  510. 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, 2026-9-23 15:19 , Processed in 0.071497 second(s), 15 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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