#RequireAdmin
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#Include <GuiStatusBar.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <WinAPI.au3>
#include <MsgBoxConstants.au3>
#include <File.au3>
#include <GuiMenu.au3>
Global $TITLE = "多合一映像全能处理工具 V201706"
Global $WinDism, $imagex,$wimlib,$wimDismPath_86,$wimDismPath_64,$imagexPath_86,$imagexPath_64,$wimlibPath_86,$wimlibPath_64
$wimDismPath_86=IniRead ( @ScriptDir &"\config.ini", "DISM", "32bit", "NotFound" )
$wimDismPath_64=IniRead ( @ScriptDir &"\config.ini", "DISM", "64bit", "NotFound" )
$imagexPath_86=IniRead ( @ScriptDir &"\config.ini", "imagex", "32bit", "NotFound" )
$imagexPath_64=IniRead ( @ScriptDir &"\config.ini", "imagex", "64bit", "NotFound" )
$wimlibPath_86=IniRead ( @ScriptDir &"\config.ini", "wimlib", "32bit", "NotFound" )
$wimlibPath_64=IniRead ( @ScriptDir &"\config.ini", "wimlib", "64bit", "NotFound" )
$WimlibVersion_Display=IniRead ( @ScriptDir &"\config.ini", "wimlib", "version", "NotFound" )
$imagex60=IniRead ( @ScriptDir &"\config.ini", "imagex", "imagex V6.0", "NotFound" )
If FileExists(@WindowsDir&"\system32\dism.exe") Then
$WinDism=@WindowsDir&"\system32\dism.exe"
Else
If @OSArch = 'X64' Then
$WinDism=@ScriptDir &"" &$wimDismPath_64
Else
$WinDism=@ScriptDir &"" &$wimDismPath_86
EndIf
EndIf
If FileExists(@WindowsDir&"\system32\imagex.exe") Then
$imagex=@WindowsDir&"\system32\imagex.exe"
Else
If @OSArch = 'X64' Then
$imagex=@ScriptDir &""&$imagexPath_64
Else
$imagex=@ScriptDir &""&$imagexPath_86
EndIf
EndIf
If @OSArch = 'X64' Then
$wimlib=@ScriptDir &""&$wimlibPath_64
Else
$wimlib=@ScriptDir &""&$wimlibPath_86
EndIf
;以上是定义文件路径
Global $DismVersion,$ImagexVersion,$WimlibVersion
$DismVersion=StringRegExp(FileGetVersion($WinDism ),'(?<grp0>[^\D]+)\.',3)
$ImagexVersion=StringRegExp(FileGetVersion($imagex ),'(?<grp0>[^\D]+)\.',3)
For $i=0 To UBound($DismVersion) - 1
$DismVersion_Display="V"&$DismVersion[0]&"."&$DismVersion[1]
$ImagexVersion_Display="V"&$ImagexVersion[0]&"."&$ImagexVersion[1]
Next
;以上是获取文件版本号
;定义窗体
$Form_main = GUICreate($TITLE, 900, 540, -1, -1)
$MyTab = GUICtrlCreateTab(20, 20, 860, 430)
Global $Edit = GUICtrlCreateEdit("",20, 455, 860, 60)
GUICtrlSetData(-1, "<返回值显示区域>")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$TabSheet2 = GUICtrlCreateTabItem("挂载释放")
$Group2_1 = GUICtrlCreateGroup("", 20, 35, 858, 380)
$Label2_1 = GUICtrlCreateLabel("映像文件:",50, 56, 60, 25)
GUICtrlSetFont(-1, 9.5, 400, 0, "Arial")
$Input_WIMfile = GUICtrlCreateInput("", 50, 80, 325, 30)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
$Button_wimfileBrowse = GUICtrlCreateButton("浏览", 385, 80, 45, 30)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
$Label2_2 = GUICtrlCreateLabel("挂载目录:", 470, 56, 60, 25)
GUICtrlSetFont(-1, 9.5, 400, 0, "Arial")
$Input_mountdir = GUICtrlCreateInput("", 465, 80, 325, 30)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
$Button_MountBrowse = GUICtrlCreateButton("浏览", 800, 80, 45, 30)
$Labe2_VolName = GUICtrlCreateLabel("镜像卷名:", 50, 120, 60, 25)
$combo_VolName= GUICtrlCreateCombo("", 50, 140, 325, 30)
$Checkbox2_1 = GUICtrlCreateCheckbox("校验", 270, 183, 50, 17)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
$Checkbox2_2 = GUICtrlCreateCheckbox("检查", 390, 183, 50, 17)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
$Radio_apply = GUICtrlCreateRadio("释放", 50, 183, 40, 17)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
$Radio_mount = GUICtrlCreateRadio("挂载", 160, 183, 40, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
If BitAND(GUICtrlRead($Radio_mount), $GUI_CHECKED) Then
GUICtrlSetState($Checkbox2_2, $GUI_DISABLE)
ElseIf Not BitAND(GUICtrlRead($Radio_mount), $GUI_CHECKED) Then
GUICtrlSetState($Checkbox2_2, $GUI_ENABLE)
EndIf
$Label2_3 = GUICtrlCreateLabel("处理方式:", 470, 120, 60, 25)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
$Combo2_1 = GUICtrlCreateCombo("", 465, 140, 325, 30, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_SIMPLE,$CBS_UPPERCASE))
GUICtrlSetData(-1, 'dism '&$DismVersion_Display&"|"&'imagex '&$ImagexVersion_Display,'dism '&$DismVersion_Display)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
$Checkbox_write = GUICtrlCreateCheckbox("可写挂载", 500, 183, 80, 17)
If Not BitAND(GUICtrlRead($Radio_mount), $GUI_CHECKED) Then
GUICtrlSetState(-1, $GUI_DISABLE)
EndIf
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
$Button2_1 = GUICtrlCreateButton("挂载映像", 650, 178, 73, 25)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
GUICtrlSetState(-1, $GUI_DISABLE)
$Group2_2 = GUICtrlCreateGroup("", 48, 215, 805, 200,$WS_BORDER)
Local $idListview = GUICtrlCreateListView("", 50, 220, 800,190,-1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
_GUICtrlListView_AddColumn($idListview, "序号", 60, 2)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
_GUICtrlListView_AddColumn($idListview, " 映像文件", 200, 2)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
_GUICtrlListView_AddColumn($idListview, "挂载卷号", 80, 2)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
_GUICtrlListView_AddColumn($idListview, "映像名称", 200, 2)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
_GUICtrlListView_AddColumn($idListview, " 挂载目录", 200, 2)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
_GUICtrlListView_AddColumn($idListview, "读/写", 50, 2)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
$Handle = GUICtrlGetHandle(-1)
GUICtrlSendMsg($idListview, $LVM_DELETEALLITEMS, 0, 0);禁止重复添加列表
Mountinfo();刷新列表
$Button_suaxin = GUICtrlCreateButton("刷新列表", 630, 420, 73, 23)
$Checkbox_save = GUICtrlCreateCheckbox("保存更改", 520, 423, 80, 17)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
$Button2_2 = GUICtrlCreateButton("卸载映像", 750, 420, 73, 23)
;GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
If Not BitAND(GUICtrlRead($Radio_mount), $GUI_CHECKED) Then
GUICtrlSetState(-1, $GUI_DISABLE)
EndIf;==>TabSheet2 结束
GUISetState(@SW_SHOW, $Form_main)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
;==>TabSheet1结束 TabSheet2开始
Case $Button_MountBrowse
If BitAND(GUICtrlRead($Radio_apply), $GUI_CHECKED) Then
GUICtrlSetData($Label2_2, "释放目录")
$file = FileSelectFolder("请选择一个目录", "", 1, "", $Form_main)
If $file<>"" Then
GUICtrlSetData($Input_mountdir, $file)
EndIf
If BitAND(GUICtrlRead($Input_WIMfile)<>"",GUICtrlRead($Input_mountdir)<>"") Then
GUICtrlSetState($Button2_1, $GUI_ENABLE)
EndIf
ElseIf Not BitAND(GUICtrlRead($Radio_apply), $GUI_CHECKED) Then
GUICtrlSetData($Label2_2, "挂载目录")
$file = FileSelectFolder("请选择一个目录", "", 1, "", $Form_main)
If $file<>"" Then
GUICtrlSetData($Input_mountdir, $file)
EndIf
; If StringRight($file, 1) = "" Then GUICtrlSetData($Input_mountdir, StringTrimRight($file, 1))
If BitAND(GUICtrlRead($Input_WIMfile)<>"",GUICtrlRead($Input_mountdir)<>"") Then
GUICtrlSetState($Button2_1, $GUI_ENABLE)
EndIf
EndIf
Case $Button_wimfileBrowse
If BitAND(GUICtrlRead($Radio_mount), $GUI_CHECKED) Then
$file = FileOpenDialog("请选择一个映像文件", "", "wim文件 (*.wim)", 1, "", $Form_main)
If $file<>"" Then
GUICtrlSetData($Input_WIMfile, $file)
EndIf
WIMInfo()
If BitAND(GUICtrlRead($Input_WIMfile)<>"",GUICtrlRead($Input_mountdir)<>"") Then
GUICtrlSetState($Button2_1, $GUI_ENABLE)
GUICtrlSetState($Button2_2, $GUI_ENABLE)
EndIf
ElseIf Not BitAND(GUICtrlRead($Radio_mount), $GUI_CHECKED) Then
$file = FileOpenDialog("请选择一个映像文件", "", "WIM文件 (*.wim)|SWM文件(*.SWM)", 1, "", $Form_main)
If $file<>"" Then
GUICtrlSetData($Input_WIMfile, $file)
EndIf
WIMInfo()
If BitAND(GUICtrlRead($Input_WIMfile)<>"",GUICtrlRead($Input_mountdir)<>"") Then
GUICtrlSetState($Button2_1, $GUI_ENABLE)
GUICtrlSetState($Button2_2, $GUI_ENABLE)
EndIf
EndIf
Case $Combo2_1
$combooneVol=StringRegExp(GUICtrlRead($Combo2_1),'(?<grp0>[^ ]+)',3)
For $i=0 To UBound($combooneVol) -1
Next
If $combooneVol[0]="Wimlib" Then
GUICtrlSetState($Radio_mount,$GUI_DISABLE )
GUICtrlSetState($Radio_mount,$GUI_UNCHECKED)
Else
GUICtrlSetState($Radio_mount,$GUI_ENABLE )
EndIf
Case $Radio_apply
GUICtrlSetData($Button2_1, "释放映像")
GUICtrlSetData($Label2_2, "释放目录")
GUICtrlSetState($Checkbox_write,$GUI_DISABLE )
GUICtrlSetState($Button2_2,$GUI_DISABLE )
GUICtrlSetState($Checkbox_save,$GUI_DISABLE )
GUICtrlSetData($Combo2_1, "")
GUICtrlSetData($Combo2_1,'dism '&$DismVersion_Display&"|"&'imagex '&$ImagexVersion_Display&"|"&'wimlib '&$WimlibVersion_Display,'dism '&$DismVersion_Display)
GUICtrlSetState($Button_suaxin,$GUI_DISABLE )
GUICtrlSetState($Checkbox2_1, $GUI_ENABLE)
GUICtrlSetState($Checkbox2_2,$GUI_ENABLE)
Case $Radio_mount
GUICtrlSetData($Button2_1, "挂载映像")
GUICtrlSetData($Label2_2, "挂载目录")
GUICtrlSetState($Checkbox_write,$GUI_ENABLE)
GUICtrlSetState($Button2_2,$GUI_ENABLE )
GUICtrlSetData($Combo2_1, "")
GUICtrlSetData($Combo2_1, 'dism '&$DismVersion_Display&"|"&'imagex '&$ImagexVersion_Display,'dism '&$DismVersion_Display)
GUICtrlSetState($Button_suaxin,$GUI_ENABLE)
GUICtrlSetState($Checkbox2_1, $GUI_ENABLE)
GUICtrlSetState($Checkbox2_2, $GUI_DISABLE)
Case $Button2_1
If BitAND(GUICtrlRead($Radio_mount), $GUI_CHECKED) Then
GUICtrlSendMsg($idListview, $LVM_DELETEALLITEMS, 0, 0);禁止重复添加列表
mount_image()
ElseIf BitAND(GUICtrlRead($Radio_apply), $GUI_CHECKED) Then
Apply_image()
EndIf
Case $Button2_2
UN_mount_image()
Case $Button_suaxin
GUICtrlSendMsg($idListview, $LVM_DELETEALLITEMS, 0, 0);禁止重复添加列表
Mountinfo();刷新列表
;==>TabSheet2结束 TabSheet3开始
EndSwitch
WEnd
Func acquire_handling();==>获取处理方式的值开始
Global $combooneVol_b=StringRegExp(GUICtrlRead($Combo2_1),'(?<grp0>[^ ]+)',3)
For $i=0 To UBound($combooneVol_b) -1
Next
EndFunc;==>获取处理方式的值结束
Func Apply_image();==>释放映像开始
GUICtrlSetState($Button2_1,$GUI_DISABLE)
GUICtrlSetState($Button2_2,$GUI_DISABLE)
Local $bool = False
acquire_handling()
Local $Input_WIMfileval=GUICtrlRead($Input_WIMfile)
Local $Input_mountdirval=GUICtrlRead($Input_mountdir)
Local $indexNo=StringLeft(GUICtrlRead($combo_VolName),1)
Local $WIM_VOL_Name=StringMid(GUICtrlRead($combo_VolName),3,-1)
Local $sread="写"
If Not FileExists($Input_mountdirval) Then DirCreate($Input_mountdirval)
If DirGetSize($Input_mountdirval)>0 Then
MsgBox(0,"","挂载目录不为空,强制挂载到该目录可能造成挂载失败!!!",10)
GUICtrlSetState($Edit, $GUI_ENABLE)
GUICtrlSetState($Button2_1,$GUI_ENABLE)
GUICtrlSetState($Button2_2,$GUI_DISABLE)
Else
Local $szExt=StringRight($Input_WIMfileval,4)
Local $Cmdpath = StringSplit($Input_WIMfileval, "") ;按\拆分路径
Local $Cmdname = StringSplit($Cmdpath[$Cmdpath[0]], ".") ;按.拆分文件名,$Cmdpath[$Cmdpath[0]]表示\拆分得到的最后一个字符串
Local $szFName = $Cmdname[1]
If $combooneVol_b[0]="DISM" Then
If $szExt=".WIM" Then
Local $applywim=Run(@ComSpec & ' /C ' & $WinDism & ' /Apply-Image /ImageFile:' & $Input_WIMfileval & ' /index:'& $indexNo & ' /ApplyDir:' & $Input_mountdirval&apply_Check(), @WindowsDir & '\system32',@SW_HIDE, $STDOUT_CHILD);dism应用释放WIM文件
ElseIf $szExt=".swm" Then
Local $applywim=Run(@ComSpec & ' /C ' & $WinDism & ' /Apply-Image /ImageFile:' & $Input_WIMfileval & ' /SWMFile:'& $szFName&'*'& $szExt&' /ApplyDir:' & $Input_mountdirval&' /index:'& $indexNo&apply_Check(), @WindowsDir & '\system32',@SW_HIDE, $STDOUT_CHILD);dism应用释放SWM文件
EndIf
While 1
$line = StdoutRead($applywim)
If @error Then ExitLoop
GUICtrlSetData($Edit, $line, -1)
Wend
GUICtrlSetState($Edit, $GUI_ENABLE)
GUICtrlSetState($Button2_1,$GUI_ENABLE)
GUICtrlSetState($Button2_2,$GUI_DISABLE)
GUICtrlSetState($Checkbox_write,$GUI_DISABLE)
GUICtrlSetState( $Checkbox_save,$GUI_DISABLE)
ElseIf $combooneVol_b[0]="imagex" Then
If $szExt=".WIM" Then
Local $applywim=Run(@ComSpec & ' /C ' & $imagex & ' /apply '&$Input_WIMfileval&' '&$indexNo&' ' & $Input_mountdirval&apply_Check(),@WindowsDir & '\system32',@SW_HIDE, $STDOUT_CHILD);利用imagex释放WIM映像
ElseIf $szExt=".swm" Then
Local $applywim=Run(@ComSpec & ' /C ' & $imagex & ' /apply '&$Input_WIMfileval&' /ref '& $szFName&'*'& $szExt&' '&$indexNo&' ' & $Input_mountdirval&apply_Check(),@WindowsDir & '\system32',@SW_HIDE, $STDOUT_CHILD);利用imagex释放SWM映像
EndIf
While 1
$line = StdoutRead($applywim)
If @error Then ExitLoop
GUICtrlSetData($Edit, $line, -1)
Wend
GUICtrlSetState($Edit, $GUI_ENABLE)
GUICtrlSetState($Button2_1,$GUI_ENABLE)
GUICtrlSetState($Button2_2,$GUI_DISABLE)
GUICtrlSetState($Checkbox_write,$GUI_DISABLE)
GUICtrlSetState( $Checkbox_save,$GUI_DISABLE)
ElseIf $combooneVol_b[0]="Wimlib" Then
If $szExt=".WIM" Then
Local $applywim=Run(@ComSpec & ' /C ' &$wimlib&' apply ' &$Input_WIMfileval & ' ' & $indexNo & ' ' &$Input_mountdirval&apply_Check(),@WindowsDir & '\system32',@SW_HIDE, $STDOUT_CHILD);利用wimlib-imagex释放映像
ElseIf $szExt=".swm" Then
MsgBox(0,"","Wimlib暂时不支持SWM格式文件的释放操作!!")
EndIf
While 1
$line = StdoutRead($applywim)
If @error Then ExitLoop
GUICtrlSetData($Edit, $line, -1)
Wend
GUICtrlSetState($Edit, $GUI_ENABLE)
GUICtrlSetState($Button2_1,$GUI_ENABLE)
GUICtrlSetState($Button2_2,$GUI_DISABLE)
GUICtrlSetState($Checkbox_write,$GUI_DISABLE)
GUICtrlSetState( $Checkbox_save,$GUI_DISABLE)
EndIf
Local $iFileSize = DirGetSize(GUICtrlRead($Input_mountdir))
If $iFileSize>0 Then
MsgBox(0,"","释放成功",5)
shellexecute($Input_mountdirval)
ElseIf $iFileSize=0 Then
MsgBox(0,"","释放失败,请检查失败原因!!",5)
EndIf
EndIf
EndFunc;==>释放映像结束
Func Mountinfo();==>获取挂载信息开始
Local $sMountInfo = @TempDir&"\MountInfo.txt"
FileDelete($sMountInfo)
RunWait(@ComSpec & ' /C ' & $WinDism & ' /Get-MountedWimInfo'&' > '& $sMountInfo, @WindowsDir & '\system32', @SW_HIDE)
$MountTxt = FileRead($sMountInfo)
Local $VolNO = StringRegExp($MountTxt, '映像索引: (\V+)', 3)
Local $WimFile = StringRegExp($MountTxt, '映像文件: (\V+)', 3)
Local $MountPath=StringRegExp($MountTxt, '安装目录: (\V+)', 3)
Local $MountRW=StringRegExp($MountTxt, '安装的读/写: (\V+)', 3)
For $i = 0 To UBound($mountpath) - 1
If $MountRW[$i]="否" Then
Local $Mount_RW="只读"
Else
Local $Mount_RW="可写"
EndIf
GUICtrlCreateListViewItem($i+1&"|"&$WimFile[$i]&"|"&$VolNO[$i]&"|"&$MountPath[$i]&"|"&$Mount_RW,$idListview)
Next
FileDelete($sMountInfo)
EndFunc;==>获取挂载信息结束
Func WIMInfo();==>获取映像信息开始
Local $sFilePath = @TempDir & '\wiminfo.txt'
FileDelete($sFilePath)
GUICtrlSetData($combo_VolName, "")
;GUICtrlSetData($WimIndex, "")
RunWait(@ComSpec & ' /C ' & '@echo off &' & $WinDism & ' /Get-ImageInfo /imagefile:"' & GUICtrlRead($Input_WIMfile) & '" >' & $sFilePath, @WindowsDir & '\system32', @SW_HIDE)
$wimtxt = FileRead($sFilePath)
Local $INDEX = StringRegExp($wimtxt, '索引: (\V+)', 3)
Local $name = StringRegExp($wimtxt, '名称: (\V+)', 3)
For $i = 0 To UBound($name) - 1
GUICtrlSetData($combo_VolName, $INDEX[$i] & "." & $name[$i], $INDEX[0] & "." & $name[0])
; GUICtrlSetData($WimIndex, $INDEX[$i], $INDEX[0])
Next
FileDelete($sFilePath)
EndFunc ;==>获取映像信息结束
Func mount_image();==>挂载映像开始
GUICtrlSetState($Button2_1,$GUI_DISABLE)
GUICtrlSetState($Button2_2,$GUI_DISABLE)
Local $bool = False
Local $Input_WIMfileval=GUICtrlRead($Input_WIMfile)
Local $Input_mountdirval=GUICtrlRead($Input_mountdir)
Local $indexNo=StringLeft(GUICtrlRead($combo_VolName),1)
Local $WIM_VOL_Name=StringMid(GUICtrlRead($combo_VolName),3,-1)
acquire_handling()
If Not FileExists($Input_mountdirval) Then DirCreate($Input_mountdirval)
If DirGetSize($Input_mountdirval)>0 Then
MsgBox(0,"","挂载目录不为空,强制挂载到该目录可能造成挂载失败!!!",10)
GUICtrlSetState($Edit, $GUI_ENABLE)
GUICtrlSetState($Button2_1,$GUI_ENABLE)
GUICtrlSetState($Button2_2,$GUI_ENABLE)
Else
Select
Case $combooneVol_b[0]="DISM"
If BitAND(GUICtrlRead($Checkbox_write), $GUI_CHECKED) Then
Local $mountwim=Run(@ComSpec & ' /C ' & $WinDism & ' /Mount-Wim /WimFile:' & $Input_WIMfileval & ' /index:'& $indexNo & ' /MountDir:' & $Input_mountdirval&mountcheck(), @WindowsDir & '\system32',@SW_HIDE, $STDOUT_CHILD)
ElseIf Not BitAND(GUICtrlRead($Checkbox_write), $GUI_CHECKED) Then
Local $mountwim=Run(@ComSpec & ' /C ' & $WinDism & ' /Mount-Wim /WimFile:' & $Input_WIMfileval & ' /index:'& $indexNo & ' /MountDir:' & $Input_mountdirval&' /ReadOnly'&mountcheck(), @WindowsDir & '\system32',@SW_HIDE, $STDOUT_CHILD)
EndIf
While 1
$line = StdoutRead($mountwim)
If @error Then ExitLoop
GUICtrlSetData($Edit, $Line, -1)
Wend
GUICtrlSetState($Edit, $GUI_ENABLE)
GUICtrlSetState($Button2_1,$GUI_ENABLE)
GUICtrlSetState($Button2_2,$GUI_ENABLE)
GUICtrlSetState($Checkbox_write,$GUI_UNCHECKED)
Local $iFileSize = DirGetSize(GUICtrlRead($Input_mountdir))
If $iFileSize>0 Then
Mountinfo()
ElseIf $iFileSize=0 Then
MsgBox(0,"","挂载失败,请检查失败原因!!",5)
EndIf
Case $combooneVol_b[0]="imagex"
If BitAND(GUICtrlRead($Checkbox_write), $GUI_CHECKED) Then
Local $mountwim=Run(@ComSpec & ' /C ' & $imagex & ' /MOUNTRW '&$Input_WIMfileval&' '&$indexNo&' ' & $Input_mountdirval&mountcheck(),@WindowsDir & '\system32',@SW_HIDE, $STDOUT_CHILD);利用imagex可写挂载
ElseIf Not BitAND(GUICtrlRead($Checkbox_write), $GUI_CHECKED) Then
Local $mountwim=Run(@ComSpec & ' /C ' & $imagex & ' /MOUNT '&$Input_WIMfileval&' '&$indexNo&' ' & $Input_mountdirval&mountcheck(),@WindowsDir & '\system32',@SW_HIDE, $STDOUT_CHILD);利用imagex只读挂载
EndIf
While 1
$line = StdoutRead($mountwim)
If @error Then ExitLoop
GUICtrlSetData($Edit, $Line, -1)
Wend
GUICtrlSetState($Edit, $GUI_ENABLE)
GUICtrlSetState($Button2_1,$GUI_ENABLE)
GUICtrlSetState($Button2_2,$GUI_ENABLE)
GUICtrlSetState($Checkbox_write,$GUI_UNCHECKED)
Local $iFileSize = DirGetSize(GUICtrlRead($Input_mountdir))
If $iFileSize>0 Then
Mountinfo()
ElseIf $iFileSize=0 Then
MsgBox(0,"","挂载失败,请检查失败原因!!",5)
EndIf
Case Else
GUICtrlSetState($Edit, $GUI_ENABLE)
GUICtrlSetState($Button2_1,$GUI_ENABLE)
GUICtrlSetState($Button2_2,$GUI_ENABLE)
EndSelect
EndIf
EndFunc;==>挂载映像结束
Func UN_mount_image();==>卸载映像开始
acquire_handling()
GUICtrlSetState($Button2_1,$GUI_DISABLE)
GUICtrlSetState($Button2_2,$GUI_DISABLE)
Local $bool = False
Local $Input_mountdirval=GUICtrlRead($Input_mountdir)
Local $Listview = _GUICtrlListView_GetSelectedIndices($idListview);选中列表项
Local $Code = _GUICtrlListView_GetItemText($idListview, Number($Listview),3)
Local $RWstate= _GUICtrlListView_GetItemText($idListview, Number($Listview),4)
If $Code="" Then
MsgBox(4160,"","你好像还未选中需要卸载的映像,让我好为难哟!!",5)
GUICtrlSetState($Edit, $GUI_ENABLE)
GUICtrlSetState($Button2_1,$GUI_ENABLE)
GUICtrlSetState($Button2_2,$GUI_ENABLE)
Else
If $RWstate="只读" Then
GUICtrlSetState($Checkbox_save,$GUI_UNCHECKED)
GUICtrlSetState($Checkbox_save,$GUI_DISABLE)
ElseIf $RWstate="可写" Then
GUICtrlSetState($Checkbox_save,$GUI_ENABLE)
EndIf
Select
Case $combooneVol_b[0]="DISM"
If BitAND(GUICtrlRead($Checkbox_save), $GUI_CHECKED) Then
Local $unmountwim=Run(@ComSpec & ' /C ' & $WinDism & ' /Unmount-Wim /MountDir:' & $Code &' /commit', @WindowsDir & '\system32',@SW_HIDE, $STDOUT_CHILD)
ElseIf Not BitAND(GUICtrlRead($Checkbox_save), $GUI_CHECKED) Then
Local $unmountwim=Run(@ComSpec & ' /C ' & $WinDism & ' /Unmount-Wim /MountDir:' & $Code &' /discard', @WindowsDir & '\system32',@SW_HIDE, $STDOUT_CHILD)
EndIf
While 1
$line = StdoutRead($unmountwim)
If @error Then ExitLoop
GUICtrlSetData($Edit, $Line, -1)
Wend
GUICtrlSetState($Edit, $GUI_ENABLE)
GUICtrlSetState($Button2_1,$GUI_ENABLE)
GUICtrlSetState($Button2_2,$GUI_ENABLE)
GUICtrlSetState($Checkbox_save,$GUI_ENABLE)
GUICtrlSetState($Checkbox_save,$GUI_UNCHECKED)
Local $iFileSize = DirGetSize(GUICtrlRead($Input_mountdir))
If $iFileSize=0 Then
GUICtrlSendMsg($idListview, $LVM_DELETEALLITEMS, 0, 0);禁止重复添加列表
Mountinfo();刷新列表
ElseIf $iFileSize>0 Then
MsgBox(0,"","卸载失败……",5)
EndIf
Case $combooneVol_b[0]="imagex"
If BitAND(GUICtrlRead($Checkbox_save), $GUI_CHECKED) Then
Local $unmountwim=Run(@ComSpec & ' /C ' & $imagex & ' /unmount /commit ' & $Code,@WindowsDir & '\system32',@SW_HIDE, $STDOUT_CHILD)
ElseIf Not BitAND(GUICtrlRead($Checkbox_save), $GUI_CHECKED) Then
Local $unmountwim=Run(@ComSpec & ' /C ' & $imagex & ' /unmount '& $Code,@WindowsDir & '\system32',@SW_HIDE, $STDOUT_CHILD)
EndIf
While 1
$line = StdoutRead($unmountwim)
If @error Then ExitLoop
GUICtrlSetData($Edit, $Line, -1)
Wend
GUICtrlSetState($Edit, $GUI_ENABLE)
GUICtrlSetState($Button2_1,$GUI_ENABLE)
GUICtrlSetState($Button2_2,$GUI_ENABLE)
GUICtrlSetState($Checkbox_save,$GUI_ENABLE)
GUICtrlSetState($Checkbox_save,$GUI_UNCHECKED)
Local $iFileSize = DirGetSize(GUICtrlRead($Input_mountdir))
If $iFileSize=0 Then
GUICtrlSendMsg($idListview, $LVM_DELETEALLITEMS, 0, 0);禁止重复添加列表
Mountinfo();刷新列表
ElseIf $iFileSize>0 Then
MsgBox(0,"","卸载失败……",5)
EndIf
Case $combooneVol_b[0]="wimlib"
MsgBox(0,"","Wimlib-imagex暂不支持挂载操作")
GUICtrlSetState($Edit, $GUI_ENABLE)
GUICtrlSetState($Button2_1,$GUI_ENABLE)
GUICtrlSetState($Button2_2,$GUI_ENABLE)
GUICtrlSetState($Checkbox_save,$GUI_ENABLE)
GUICtrlSetState($Checkbox_write,$GUI_UNCHECKED)
EndSelect
EndIf
EndFunc;==>卸载映像结束
;==>选择卡2参数开始
Func mountcheck();==>挂载参数开始
acquire_handling()
If $combooneVol_b[0]="dism" Then
If BitAND(GUICtrlRead($Checkbox2_1),$GUI_CHECKED) Then
Return " /CheckIntegrity"
ElseIf Not BitAND(GUICtrlRead($Checkbox2_1),$GUI_CHECKED) Then
Return ""
EndIf
ElseIf $combooneVol_b[0]="imagex" Then
If BitAND(GUICtrlRead($Checkbox2_1),$GUI_CHECKED) Then
Return " /Check"
ElseIf Not BitAND(GUICtrlRead($Checkbox2_1),$GUI_CHECKED) Then
Return ""
EndIf
EndIf
EndFunc;==>挂载参数结束
Func apply_Check();==>释放参数开始
acquire_handling()
$nText = ''
For $i = $Checkbox2_1 To $Checkbox2_2
If BitAND(GUICtrlRead($i), $GUI_CHECKED) Then $nText &= $i
Next
If $combooneVol_b[0]="dism" Then
If $nText = 3 Then
Return " /Verify"
ElseIf $nText = 4 Then
Return " /CheckIntegrity"
ElseIf $nText = 34 Then
Return " /Verify /CheckIntegrity"
Else
Return ""
EndIf
ElseIf $combooneVol_b[0]="imagex" Then
If $nText = 3 Then
Return " /Verify"
ElseIf $nText = 4 Then
Return " /CHECK"
ElseIf $nText = 34 Then
Return " /Verify /CHECK"
Else
Return ""
EndIf
ElseIf $combooneVol_b[0]="wimlib" Then
If $nText = 3 Then
Return ""
ElseIf $nText = 4 Then
Return " --check"
ElseIf $nText = 34 Then
Return " --check"
Else
Return ""
EndIf
Else
Return ""
EndIf
EndFunc ;==>挂释放参数结束
;==>选择卡2参数结束.