|
我想做一个映像信息列表,但通过dism /Get-MountedWimInfo命令只能获取到映像索引、映像文件、安装目录、读写等信息,而不能获取到映像名称和映像描述等。我的想法是再运行dism /Get-ImageInfo命令生成带序号的wiminfo信息文件,现在文件已经生成,想提取与dism /Get-MountedWimInfo命令获取到的映像文件及索引相匹配的映像名称和描述,不知怎么做?望高手指点。#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>
#include <Math.au3>
Global $WinDism, $imagex,$wimlib,$wimDismPath_86,$wimDismPath_64,$imagexPath_86,$imagexPath_64,$wimlibPath_86,$wimlibPath_64,$imagexVersion
$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=@ScriptDir &""&IniRead ( @ScriptDir &"\config.ini", "imagex", "imagex6.0", "NotFound" )
$imagex_Version=IniRead ( @ScriptDir &"\config.ini", "imagex", "imagex_Version", "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]
Next
If $ImagexVersion[0]&"."&$ImagexVersion[1]="0.0" Then
$ImagexVersion_Display=$imagex_Version
Else
$ImagexVersion_Display="V"&$ImagexVersion[0]&"."&$ImagexVersion[1]
EndIf
$Form_main = GUICreate("", 900, 540, -1, -1)
Global $Edit = GUICtrlCreateEdit("",20, 860, 490, 50)
GUICtrlSetData(-1, "<返回值显示区域>")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$TabSheet2 = GUICtrlCreateTabItem("挂载释放")
;$Group2_1 = GUICtrlCreateGroup("", 20, 35, 858, 380)
$Label2_1 = GUICtrlCreateLabel(" 映 像 文 件: ",50, 56, 70, 17)
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, 70, 17)
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, 80, 17)
$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, 50, 17)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
$Radio_mount = GUICtrlCreateRadio("挂 载", 160, 183, 50, 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, 70, 17)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
$Combo2_1 = GUICtrlCreateCombo("", 465, 140, 325, 30, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_SIMPLE,$CBS_UPPERCASE))
If Syscode(@HomeDrive) >= 6.0 Then
GUICtrlSetData(-1, 'dism '&$DismVersion_Display&"|"&'imagex '&$ImagexVersion_Display,'dism '&$DismVersion_Display)
Else
GUICtrlSetData(-1, 'dism '&$DismVersion_Display&"|"&'imagex '&$ImagexVersion_Display&"|imagex V6.0 (03PE专用)",'dism '&$DismVersion_Display)
EndIf
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
$Checkbox_write = GUICtrlCreateCheckbox("可 写 挂 载", 500, 183, 75, 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, " 映像文件", 150, 2)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
_GUICtrlListView_AddColumn($idListview, "卷号", 50, 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, " 镜像描述", 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)
;GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
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($Input_WIMfile)
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($Input_WIMfile)
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 )
GUICtrlSetState($Button_suaxin,$GUI_DISABLE )
GUICtrlSetState($Checkbox2_1, $GUI_ENABLE)
GUICtrlSetState($Checkbox2_2,$GUI_ENABLE)
GUICtrlSetData($Combo2_1, "")
If Syscode(@HomeDrive) >= 6.0 Then
GUICtrlSetData($Combo2_1,'dism '&$DismVersion_Display&"|"&'imagex '&$ImagexVersion_Display&"|"&'wimlib '&$WimlibVersion_Display,'dism '&$DismVersion_Display)
Else
GUICtrlSetData($Combo2_1,'dism '&$DismVersion_Display&"|"&'imagex '&$ImagexVersion_Display&"|"&'wimlib '&$WimlibVersion_Display&"|imagex V6.0 (03PE专用)",'dism '&$DismVersion_Display)
EndIf
Case $Radio_mount
GUICtrlSetData($Button2_1, "挂载映像")
GUICtrlSetData($Label2_2, "挂载目录")
GUICtrlSetState($Checkbox_write,$GUI_ENABLE)
GUICtrlSetState($Button2_2,$GUI_ENABLE )
GUICtrlSetData($Combo2_1, "")
If Syscode(@HomeDrive) >= 6.0 Then
GUICtrlSetData($Combo2_1, 'dism '&$DismVersion_Display&"|"&'imagex '&$ImagexVersion_Display,'dism '&$DismVersion_Display)
Else
GUICtrlSetData($Combo2_1, 'dism '&$DismVersion_Display&"|"&'imagex '&$ImagexVersion_Display&"|imagex V6.0 (03PE专用)",'dism '&$DismVersion_Display)
EndIf
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();刷新列表
EndSwitch
WEnd
Func Apply_image();==>释放映像开始
GUICtrlSetState($Button2_1,$GUI_DISABLE)
GUICtrlSetState($Button2_2,$GUI_DISABLE)
Local $bool = False
methods(GUICtrlRead($Combo2_1))
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]
Select
Case GUICtrlRead($Combo2_1)="imagex V6.0 (03PE专用)"
If $szExt=".WIM" Then
Local $applywim=Run(@ComSpec & ' /C ' & $imagex60 & ' /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 ' & $imagex60 & ' /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
Case $combooneVol[0]="DISM"
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
Case $combooneVol[0]="imagex"
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
Case $combooneVol[0]="Wimlib"
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
EndSelect
GUICtrlSetState($Edit, $GUI_ENABLE)
GUICtrlSetState($Button2_1,$GUI_ENABLE)
GUICtrlSetState($Button2_2,$GUI_DISABLE)
GUICtrlSetState($Checkbox_write,$GUI_DISABLE)
GUICtrlSetState( $Checkbox_save,$GUI_DISABLE)
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 = @ScriptDir&"\MountInfo.txt"
Local $txt=".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
Local $sFilePath=@ScriptDir&"\WIMInfo"&$i&".txt"
GUICtrlCreateListViewItem($i+1&"|"&$WimFile[$i]&"|"&$VolNO[$i]&"|"&$MountPath[$i]&"|"&"|"&"|"&$Mount_RW,$idListview)
RunWait(@ComSpec & ' /C ' & '@echo off &' & $WinDism & ' /Get-ImageInfo /imagefile:"' &$WimFile[$i] & '" >' & $sFilePath, @WindowsDir & '\system32', @SW_HIDE)
Next
EndFunc;==>获取挂载信息结束
Func WIMInfo($AddWIMfile);==>获取映像信息开始
Local $sFilePath = @TempDir & '\wiminfo.txt'
FileDelete($sFilePath)
GUICtrlSetData($combo_VolName, "")
RunWait(@ComSpec & ' /C ' & '@echo off &' & $WinDism & ' /Get-ImageInfo /imagefile:"' &GUICtrlRead($AddWIMfile) & '" >' & $sFilePath, @WindowsDir & '\system32', @SW_HIDE)
$wimtxt = FileRead($sFilePath)
Local $INDEX = StringRegExp($wimtxt, '索引: (\V+)', 3)
Local $name = StringRegExp($wimtxt, '名称: (\V+)', 3)
Local $Description = StringRegExp($wimtxt, '描述: (\V+)', 3)
For $i = 0 To UBound($name) - 1
GUICtrlSetData($combo_VolName, $INDEX[$i] & "." & $name[$i], $INDEX[0] & "." & $name[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()
methods(GUICtrlRead($Combo2_1))
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 GUICtrlRead($Combo2_1)="imagex V6.0 (03PE专用)"
If Syscode(@HomeDrive) >= 6.0 Then
MsgBox(0+16,"错误","imagex V6.0可能不支持win7及以上版本,请谨慎选择!!")
Else
If BitAND(GUICtrlRead($Checkbox_write), $GUI_CHECKED) Then
Local $sMsg=MsgBox(1+32,"提示","你选择了可写挂载,点‘确定’开始可写挂载,点‘取消’重新选择")
If $sMsg=1 Then
Local $mountwim=Run(@ComSpec & ' /C ' & $imagex60 & ' /MOUNTRW '&'"'& $Input_WIMfileval &'"'&' '&$indexNo&' ' & '"'& $Input_mountdirval &'"'&mountcheck(),@WindowsDir & '\system32',@SW_HIDE, $STDOUT_CHILD);利用imagex可写挂载
EndIf
ElseIf Not BitAND(GUICtrlRead($Checkbox_write), $GUI_CHECKED) Then
MsgBox(1+32,"提示","你未选择可写挂载,点‘确定’开始只读挂载,点‘取消’重新选择")
Local $mountwim=Run(@ComSpec & ' /C ' & $imagex60 & ' /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
EndIf
Case $combooneVol[0]="DISM"
If BitAND(GUICtrlRead($Checkbox_write), $GUI_CHECKED) Then
MsgBox(1+32,"提示","你选择了可写挂载,点‘确定’开始可写挂载,点‘取消’重新选择")
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
MsgBox(1+32,"提示","你未选择可写挂载,点‘确定’开始只读挂载,点‘取消’重新选择")
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
Case $combooneVol[0]="imagex"
If BitAND(GUICtrlRead($Checkbox_write), $GUI_CHECKED) Then
MsgBox(1+32,"提示","你选择了可写挂载,点‘确定’开始可写挂载,点‘取消’重新选择")
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
MsgBox(1+32,"提示","你未选择可写挂载,点‘确定’开始只读挂载,点‘取消’重新选择")
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
EndSelect
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
EndIf
EndFunc;==>挂载映像结束
Func UN_mount_image();==>卸载映像开始
methods(GUICtrlRead($Combo2_1))
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 GUICtrlRead($Combo2_1)="imagex V6.0 (03PE专用)"
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
Case $combooneVol[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
Case $combooneVol[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
Case $combooneVol[0]="wimlib"
MsgBox(0,"","Wimlib-imagex暂不支持挂载操作")
EndSelect
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)
GUICtrlSendMsg($idListview, $LVM_DELETEALLITEMS, 0, 0);禁止重复添加列表
Mountinfo();刷新列表
EndIf
EndIf
EndFunc;==>卸载映像结束
Func methods($methods);==>获取处理方式的值开始
Global $combooneVol=StringRegExp($methods,'(?<grp0>[^ ]+)',3)
For $i=0 To UBound($combooneVol) -1
Next
EndFunc;==>获取处理方式的值结束
Func Compress($name);==>全局参数压缩比率
Switch $name
Case "DISM 快速压缩"
Return " /Compress:fast"
Case "DISM 中等压缩"
Return " /Compress:none"
Case "DISM 最大压缩"
Return " /Compress:maximum"
Case "imagex 无压缩"
Return " /COMPRESS none"
Case "imagex 快速压缩"
Return " /COMPRESS fast"
Case "imagex 最大压缩"
Return " /COMPRESS maximum"
Case "WIMLIB 极限压缩"
Return " --compress=LZMS"
Case "WIMLIB 最大压缩"
Return " --compress=maximum"
Case "WIMLIB 快速压缩"
Return " --compress=fast"
Case "WIMLIB 不压缩"
Return " --compress=none"
EndSwitch
EndFunc
Func Syscode($DIR);==>判断映像系统是否是win8.1及以上
Local $vercode = FileGetVersion($DIR & "\WINDOWS\system32\kernel32.dll", "FileVersion")
If $vercode Then Return StringLeft($vercode, 3)
EndFunc ;==>Syscode
;==>全局参数压缩比率结束
;==>选择卡1参数开始
;==>选择卡2参数开始
Func mountcheck();==>挂载参数开始
methods(GUICtrlRead($Combo2_1))
If $combooneVol[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[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();==>释放参数开始
methods(GUICtrlRead($Combo2_1))
$nText = ''
For $i = $Checkbox2_1 To $Checkbox2_2
If BitAND(GUICtrlRead($i), $GUI_CHECKED) Then $nText &= $i
Next
If $combooneVol[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[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[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参数结束.
;==>选择卡3参数开始
;==>选择卡4参数开始
;==>选择卡6参数结束
;==>定义参数结束
Func Mountinfo();==>获取挂载信息开始
Local $sMountInfo = @ScriptDir&"\MountInfo.txt"
Local $txt=".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
Local $sFilePath=@ScriptDir&"\WIMInfo"&$i&".txt"
GUICtrlCreateListViewItem($i+1&"|"&$WimFile[$i]&"|"&$VolNO[$i]&"|"&$MountPath[$i]&"|"&"|"&"|"&$Mount_RW,$idListview)
RunWait(@ComSpec & ' /C ' & '@echo off &' & $WinDism & ' /Get-ImageInfo /imagefile:"' &$WimFile[$i] & '" >' & $sFilePath, @WindowsDir & '\system32', @SW_HIDE)
Next
;此处已生成了wiminfo0~wiminfo2等多个文本文件,每个文件都存有每个映像的wim信息,想提取与列表相关联的名称及描述到列表相应列,不知怎么做???
EndFunc;==>获取挂载信息结束
生成的文件如下: |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?加入
×
|