Jump to content

EditBox copy selected text to Input


trashy
 Share

Recommended Posts

This is part of new tab for Easy_DISM

In the EditBox I noticed double click on the Package Name would highlight it then manually copy and paste to input 4. I would like to automate the process but what's the best way? Click on Event or CilpGet any other suggestions not sure where to start.

Tab12.jpg

Here's the code for what will become tab 12, I haven't attempted anything yet can someone point me in the right direction.

#RequireAdmin
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <GuiTab.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>
#include <Constants.au3>
#include <Process.au3>
#include <ComboConstants.au3>
#include <WinAPIDlg.au3>
#include <GuiListView.au3>
#include <ColorConstants.au3>
#include <Array.au3>
#include <String.au3>
#include <FontConstants.au3.>
#include <GuiEdit.au3>
#include <ScrollBarsConstants.au3>
#include <GuiStatusBar.au3>
#include <File.au3>

$Form1 = GUICreate("Easy_DISM", 620, 680, -1, -1, -1, BitOR($WS_EX_WINDOWEDGE, $TCS_TOOLTIPS))

$c = ' /c '
$dismon = '\Dism.exe /Online"'
$miInfo = '\Dism.exe /Get-MountedImageInfo"'

$Tab1 = GUICtrlCreateTab(24, -1, 570, 600, BitOR($TCS_MULTILINE, $TCS_FLATBUTTONS))

;Start AppPkg Tab
$TabSheet12 = GUICtrlCreateTabItem("AppPkg")
$iStart_12 = GUICtrlCreateDummy() ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$T12Checkbox1 = GUICtrlCreateCheckbox("Online", 504, 80, 60, 17)
$T12Button1 = GUICtrlCreateButton("Browse", 504, 48, 75, 25)
$T12Button2 = GUICtrlCreateButton("Browse", 416, 298, 75, 25)
$T12Button3 = GUICtrlCreateButton("ADD", 504, 298, 75, 25)
$T12Button4 = GUICtrlCreateButton("Browse", 416, 325, 75, 25)
$T12Button5 = GUICtrlCreateButton("ADD", 504, 325, 75, 25)
$T12Button6 = GUICtrlCreateButton("Remove", 504, 352, 75, 25)
$T12Button8 = GUICtrlCreateButton("AppPkg Info", 504, 440, 75, 25)
$T12Edit1 = GUICtrlCreateEdit("", 120, 80, 370, 210, $ES_READONLY + $WS_VSCROLL + $WS_HSCROLL)
GUICtrlSetData(-1, "")
$T12Edit2 = GUICtrlCreateEdit("", 120, 380, 370, 210, $ES_READONLY + $WS_VSCROLL + $WS_HSCROLL)
GUICtrlSetData(-1, @CRLF & "Remove AppPkg: Select Online or Mount Folder" & @CRLF & "          Click AppPkg Info then choose the Pkg you wish to remove." _
         & @CRLF & "          Double Click Package Name to Highlight then right click" & @CRLF & "          copy and paste to input then click remove." & @CRLF & @CRLF & "ADD App Package UNTESTED")
$T12Input1 = GUICtrlCreateInput("", 120, 48, 370, 21)
$T12Input2 = GUICtrlCreateInput("Used /SkipLicense option (error License required)", 120, 298, 281, 21)
$T12Input3 = GUICtrlCreateInput("Un Tested", 120, 325, 281, 21)
$T12Input4 = GUICtrlCreateInput("", 120, 352, 370, 21)
$T12Label1 = GUICtrlCreateLabel("Mount Folder", 45, 48, 62, 17)
$T12Label2 = GUICtrlCreateLabel("Single AppPkg", 45, 298, 70, 17)
$T12Label3 = GUICtrlCreateLabel("AppPkg Folder", 45, 325, 70, 17)
$T12Label4 = GUICtrlCreateLabel("AppPkg", 45, 352, 70, 17)
$iEnd_12 = GUICtrlCreateDummy() ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

GUICtrlCreateTabItem("")
$Button1 = GUICtrlCreateButton("EXIT", 272, 650, 75, 25)
$progress = GUICtrlCreateEdit("", 120, 600, 380, 50, $ES_READONLY)
GUISetState(@SW_SHOW, $Form1)

$Run = Run(@ComSpec & $c & @ScriptDir & $miInfo, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
ProcessWaitClose($Run, 2)
$data = StdoutRead($Run)
GUICtrlSetData($T12Edit1, $data)
;GUICtrlSetData($T2Edit1, $data)
;GUICtrlSetData($T3Edit1, $data)
;GUICtrlSetData($T4Edit1, $data)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            Exit
        Case $iStart_12 To $iEnd_12
            _Tab_12($nMsg)

    EndSwitch
WEnd

Func _Tab_12($nMsg) ;<<<<< AppPkg Tab
    Switch $nMsg
        Case $T12Checkbox1
            If GUICtrlRead($T12Checkbox1) = $Gui_Checked Then
                GUICtrlSetState($T12Input1, $GUI_DISABLE)
                GUICtrlSetState($T12Button1, $GUI_DISABLE)
            ElseIf GUICtrlRead($T12Checkbox1) = $Gui_UnChecked Then
                GUICtrlSetState($T12Input1, $GUI_ENABLE)
                GUICtrlSetState($T12Button1, $GUI_ENABLE)
            EndIf
        Case $T12Button1
            $of_T3Button1 = FileSelectFolder("Select Mount Folder: ", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", 4)
            GUICtrlSetData($T12Input1, $of_T3Button1)
            $aRun = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Get-MountedImageInfo"', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
            ProcessWaitClose($aRun, 0)
            $adata = StdoutRead($aRun)
            GUICtrlSetData($T12Edit1, $adata)
        Case $T12Button2
            $of_T3Button2 = FileOpenDialog("Select Pkg File", @HomeDrive, "AppPkg Files (*.appx;*.appxbundle)", 1 + 4, "")
            GUICtrlSetData($T12Input2, $of_T3Button2)
        Case $T12Button3
            If GUICtrlRead($T12Checkbox1) = $Gui_UnChecked Then
                If GUICtrlRead($T12Input1) = "" Then
                    MsgBox(262144, "Empty.....", "No Mount Folder Selected!")
                    Return
                EndIf
                If GUICtrlRead($T12Input2) = "" Then
                    MsgBox(262144, "Empty.....", "No AppPkg Selected!")
                    Return
                EndIf
                $output = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Image:"' & GUICtrlRead($T12Input1) & '" /Add-ProvisionedAppxPackage /PackagePath:"' & GUICtrlRead($T12Input2) & '" /SkipLicense"', '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($output)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($progress, $progout)
                        _GUICtrlEdit_Scroll($progress, $SB_SCROLLCARET)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            ElseIf GUICtrlRead($T12Checkbox1) = $Gui_Checked Then
                If GUICtrlRead($T12Input2) = "" Then
                    MsgBox(262144, "Empty.....", "No AppPkg Selected!")
                    Return
                EndIf
                $output = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Online /Add-ProvisionedAppxPackage /PackagePath:"' & GUICtrlRead($T12Input2) & '" /SkipLicense"', '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($output)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($progress, $progout)
                        _GUICtrlEdit_Scroll($progress, $SB_SCROLLCARET)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            EndIf
        Case $T12Button4
            $of_T3Button4 = FileSelectFolder("Select Pkg : ", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", 4)
            GUICtrlSetData($T12Input3, $of_T3Button4)
        Case $T12Button5
            If GUICtrlRead($T12Checkbox1) = $Gui_UnChecked Then
                If GUICtrlRead($T12Input1) = "" Then
                    MsgBox(262144, "Empty.....", "No Mount Folder Selected!")
                    Return
                EndIf
                If GUICtrlRead($T12Input3) = "" Then
                    MsgBox(262144, "Empty.....", "No AppPkg Folder Selected!")
                    Return
                EndIf
                $output = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Image:"' & GUICtrlRead($T12Input1) & '" /Add-ProvisionedAppxPackage /FolderPath:"' & GUICtrlRead($T12Input3) & '""', '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($output)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($progress, $progout)
                        _GUICtrlEdit_Scroll($progress, $SB_SCROLLCARET)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            ElseIf GUICtrlRead($T12Checkbox1) = $Gui_Checked Then
                If GUICtrlRead($T12Input3) = "" Then
                    MsgBox(262144, "Empty.....", "No AppPkg Folder Selected!")
                    Return
                EndIf
                $output = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Online /Add-ProvisionedAppxPackage /FolderPath:"' & GUICtrlRead($T12Input3) & '""', '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($output)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($progress, $progout)
                        _GUICtrlEdit_Scroll($progress, $SB_SCROLLCARET)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            EndIf
        Case $T12Button6
            If GUICtrlRead($T12Checkbox1) = $Gui_UnChecked Then
                If GUICtrlRead($T12Input1) = "" Then
                    MsgBox(262144, "Empty.....", "No Mount Folder Selected!")
                    Return
                EndIf
                If GUICtrlRead($T12Input4) = "" Then
                    MsgBox(262144, "Empty.....", "Enter an AppPkg to remove!")
                    Return
                EndIf
                $zRun = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Image:"' & GUICtrlRead($T12Input1) & '" /Remove-ProvisionedAppxPackage /PackageName:"' & GUICtrlRead($T12Input4) & '" & Exit"', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($zRun)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($T12Edit2, $progout)
                        _GUICtrlEdit_Scroll($T12Edit2, $SB_SCROLLCARET)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            ElseIf GUICtrlRead($T12Checkbox1) = $Gui_Checked Then
                If GUICtrlRead($T12Input4) = "" Then
                    MsgBox(262144, "Empty.....", "Enter an AppPkg to remove!")
                    Return
                EndIf

                $bRun = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Online /Remove-ProvisionedAppxPackage /PackageName:"' & GUICtrlRead($T12Input4) & '""', '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($bRun)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($T12Edit2, $progout)
                        _GUICtrlEdit_Scroll($T12Edit2, $SB_SCROLLCARET)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            EndIf
        Case $T12Button8
            If GUICtrlRead($T12Checkbox1) = $Gui_UnChecked Then
                If GUICtrlRead($T12Input1) = "" Then
                    MsgBox(262144, "Empty.....", "No Mount Folder Selected!")
                    Return
                EndIf
                $bRun = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Image:"' & GUICtrlRead($T12Input1) & '" /Get-ProvisionedAppxPackages"', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($bRun)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($T12Edit2, $progout)
                        _GUICtrlEdit_Scroll($T12Edit2, $SB_SCROLLCARET)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            ElseIf GUICtrlRead($T12Checkbox1) = $Gui_Checked Then
                $bRun = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Online /Get-ProvisionedAppxPackages"', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($bRun)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($T12Edit2, $progout)
                        _GUICtrlEdit_Scroll($T12Edit2, $SB_SCROLLCARET)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            EndIf
    EndSwitch
EndFunc   ;==>_Tab_12

 

Link to comment
Share on other sites

You can check for double click with 2 _ispressed, Then clipboard functions.

$Window = WinGetState($GUI) 
    If BitAND($Window, 8) Then ;Window is active
        $CursorInfo = GUIGetCursorInfo($GUI) 
        If $CursorInfo[4] = $cListView Then ;Mouse over the control
            If _IsPressed("01") Then ;1 left click
                Sleep(10)
                If _IsPressed("01") Then ;second left click
                    ;stuff clipget and whatnot
                EndIf
            EndIf
        EndIf
    EndIf

 

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

@trashy Sorry for not responding to your earlier posts regarding this, unfortunately I've never added packages, only removed them, I used these in conjunction with a template ini file as you're aware, but the initial function to remove and add to the ini and/or remove directly is based upon the following function (integrated into your example above, just need to click the AppPkg Info button to see it working)

PS: Sorry about the code it's a bit of a mess, just need to find time to tidy it up :) 

#RequireAdmin
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <GuiTab.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>
#include <Constants.au3>
#include <Process.au3>
#include <ComboConstants.au3>
#include <WinAPIDlg.au3>
#include <GuiListView.au3>
#include <ColorConstants.au3>
#include <Array.au3>
#include <String.au3>
#include <FontConstants.au3.>
#include <GuiEdit.au3>
#include <ScrollBarsConstants.au3>
#include <GuiStatusBar.au3>
#include <File.au3>

$Form1 = GUICreate("Easy_DISM", 620, 680, -1, -1, -1, BitOR($WS_EX_WINDOWEDGE, $TCS_TOOLTIPS))

$c = ' /c '
$dismon = '\Dism.exe /Online"'
$miInfo = '\Dism.exe /Get-MountedImageInfo"'

$Tab1 = GUICtrlCreateTab(24, -1, 570, 600, BitOR($TCS_MULTILINE, $TCS_FLATBUTTONS))

;Start AppPkg Tab
$TabSheet12 = GUICtrlCreateTabItem("AppPkg")
$iStart_12 = GUICtrlCreateDummy() ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$T12Checkbox1 = GUICtrlCreateCheckbox("Online", 504, 80, 60, 17)
$T12Button1 = GUICtrlCreateButton("Browse", 504, 48, 75, 25)
$T12Button2 = GUICtrlCreateButton("Browse", 416, 298, 75, 25)
$T12Button3 = GUICtrlCreateButton("ADD", 504, 298, 75, 25)
$T12Button4 = GUICtrlCreateButton("Browse", 416, 325, 75, 25)
$T12Button5 = GUICtrlCreateButton("ADD", 504, 325, 75, 25)
$T12Button6 = GUICtrlCreateButton("Remove", 504, 352, 75, 25)
$T12Button8 = GUICtrlCreateButton("AppPkg Info", 504, 440, 75, 25)
$T12Edit1 = GUICtrlCreateEdit("", 120, 80, 370, 210, $ES_READONLY + $WS_VSCROLL + $WS_HSCROLL)
GUICtrlSetData(-1, "")
$T12Edit2 = GUICtrlCreateEdit("", 120, 380, 370, 210, $ES_READONLY + $WS_VSCROLL + $WS_HSCROLL)
GUICtrlSetData(-1, @CRLF & "Remove AppPkg: Select Online or Mount Folder" & @CRLF & "          Click AppPkg Info then choose the Pkg you wish to remove." _
         & @CRLF & "          Double Click Package Name to Highlight then right click" & @CRLF & "          copy and paste to input then click remove." & @CRLF & @CRLF & "ADD App Package UNTESTED")
$T12Input1 = GUICtrlCreateInput("", 120, 48, 370, 21)
$T12Input2 = GUICtrlCreateInput("Used /SkipLicense option (error License required)", 120, 298, 281, 21)
$T12Input3 = GUICtrlCreateInput("Un Tested", 120, 325, 281, 21)
$T12Input4 = GUICtrlCreateInput("", 120, 352, 370, 21)
$T12Label1 = GUICtrlCreateLabel("Mount Folder", 45, 48, 62, 17)
$T12Label2 = GUICtrlCreateLabel("Single AppPkg", 45, 298, 70, 17)
$T12Label3 = GUICtrlCreateLabel("AppPkg Folder", 45, 325, 70, 17)
$T12Label4 = GUICtrlCreateLabel("AppPkg", 45, 352, 70, 17)
$iEnd_12 = GUICtrlCreateDummy() ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

GUICtrlCreateTabItem("")
$Button1 = GUICtrlCreateButton("EXIT", 272, 650, 75, 25)
$progress = GUICtrlCreateEdit("", 120, 600, 380, 50, $ES_READONLY)
GUISetState(@SW_SHOW, $Form1)

$Run = Run(@ComSpec & $c & @ScriptDir & $miInfo, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
ProcessWaitClose($Run, 2)
$data = StdoutRead($Run)
GUICtrlSetData($T12Edit1, $data)
;GUICtrlSetData($T2Edit1, $data)
;GUICtrlSetData($T3Edit1, $data)
;GUICtrlSetData($T4Edit1, $data)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            Exit
        Case $iStart_12 To $iEnd_12
            _Tab_12($nMsg)

    EndSwitch
WEnd

Func _Tab_12($nMsg) ;<<<<< AppPkg Tab
    Switch $nMsg
        Case $T12Checkbox1
            If GUICtrlRead($T12Checkbox1) = $Gui_Checked Then
                GUICtrlSetState($T12Input1, $GUI_DISABLE)
                GUICtrlSetState($T12Button1, $GUI_DISABLE)
            ElseIf GUICtrlRead($T12Checkbox1) = $Gui_UnChecked Then
                GUICtrlSetState($T12Input1, $GUI_ENABLE)
                GUICtrlSetState($T12Button1, $GUI_ENABLE)
            EndIf
        Case $T12Button1
            $of_T3Button1 = FileSelectFolder("Select Mount Folder: ", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", 4)
            GUICtrlSetData($T12Input1, $of_T3Button1)
            $aRun = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Get-MountedImageInfo"', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
            ProcessWaitClose($aRun, 0)
            $adata = StdoutRead($aRun)
            GUICtrlSetData($T12Edit1, $adata)
        Case $T12Button2
            $of_T3Button2 = FileOpenDialog("Select Pkg File", @HomeDrive, "AppPkg Files (*.appx;*.appxbundle)", 1 + 4, "")
            GUICtrlSetData($T12Input2, $of_T3Button2)
        Case $T12Button3
            If GUICtrlRead($T12Checkbox1) = $Gui_UnChecked Then
                If GUICtrlRead($T12Input1) = "" Then
                    MsgBox(262144, "Empty.....", "No Mount Folder Selected!")
                    Return
                EndIf
                If GUICtrlRead($T12Input2) = "" Then
                    MsgBox(262144, "Empty.....", "No AppPkg Selected!")
                    Return
                EndIf
                $output = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Image:"' & GUICtrlRead($T12Input1) & '" /Add-ProvisionedAppxPackage /PackagePath:"' & GUICtrlRead($T12Input2) & '" /SkipLicense"', '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($output)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($progress, $progout)
                        _GUICtrlEdit_Scroll($progress, $SB_SCROLLCARET)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            ElseIf GUICtrlRead($T12Checkbox1) = $Gui_Checked Then
                If GUICtrlRead($T12Input2) = "" Then
                    MsgBox(262144, "Empty.....", "No AppPkg Selected!")
                    Return
                EndIf
                $output = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Online /Add-ProvisionedAppxPackage /PackagePath:"' & GUICtrlRead($T12Input2) & '" /SkipLicense"', '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($output)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($progress, $progout)
                        _GUICtrlEdit_Scroll($progress, $SB_SCROLLCARET)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            EndIf
        Case $T12Button4
            $of_T3Button4 = FileSelectFolder("Select Pkg : ", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", 4)
            GUICtrlSetData($T12Input3, $of_T3Button4)
        Case $T12Button5
            If GUICtrlRead($T12Checkbox1) = $Gui_UnChecked Then
                If GUICtrlRead($T12Input1) = "" Then
                    MsgBox(262144, "Empty.....", "No Mount Folder Selected!")
                    Return
                EndIf
                If GUICtrlRead($T12Input3) = "" Then
                    MsgBox(262144, "Empty.....", "No AppPkg Folder Selected!")
                    Return
                EndIf
                $output = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Image:"' & GUICtrlRead($T12Input1) & '" /Add-ProvisionedAppxPackage /FolderPath:"' & GUICtrlRead($T12Input3) & '""', '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($output)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($progress, $progout)
                        _GUICtrlEdit_Scroll($progress, $SB_SCROLLCARET)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            ElseIf GUICtrlRead($T12Checkbox1) = $Gui_Checked Then
                If GUICtrlRead($T12Input3) = "" Then
                    MsgBox(262144, "Empty.....", "No AppPkg Folder Selected!")
                    Return
                EndIf
                $output = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Online /Add-ProvisionedAppxPackage /FolderPath:"' & GUICtrlRead($T12Input3) & '""', '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($output)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($progress, $progout)
                        _GUICtrlEdit_Scroll($progress, $SB_SCROLLCARET)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            EndIf
        Case $T12Button6
            If GUICtrlRead($T12Checkbox1) = $Gui_UnChecked Then
                If GUICtrlRead($T12Input1) = "" Then
                    MsgBox(262144, "Empty.....", "No Mount Folder Selected!")
                    Return
                EndIf
                If GUICtrlRead($T12Input4) = "" Then
                    MsgBox(262144, "Empty.....", "Enter an AppPkg to remove!")
                    Return
                EndIf
                $zRun = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Image:"' & GUICtrlRead($T12Input1) & '" /Remove-ProvisionedAppxPackage /PackageName:"' & GUICtrlRead($T12Input4) & '" & Exit"', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($zRun)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($T12Edit2, $progout)
                        _GUICtrlEdit_Scroll($T12Edit2, $SB_SCROLLCARET)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            ElseIf GUICtrlRead($T12Checkbox1) = $Gui_Checked Then
                If GUICtrlRead($T12Input4) = "" Then
                    MsgBox(262144, "Empty.....", "Enter an AppPkg to remove!")
                    Return
                EndIf

                $bRun = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Online /Remove-ProvisionedAppxPackage /PackageName:"' & GUICtrlRead($T12Input4) & '""', '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($bRun)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($T12Edit2, $progout)
                        _GUICtrlEdit_Scroll($T12Edit2, $SB_SCROLLCARET)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            EndIf
        Case $T12Button8
            If GUICtrlRead($T12Checkbox1) = $Gui_UnChecked Then
                If GUICtrlRead($T12Input1) = "" Then
                    MsgBox(262144, "Empty.....", "No Mount Folder Selected!")
                    Return
                EndIf
                _GET_PROVISIONEDAPPXPACKAGES(@ComSpec & ' /c Dism.exe /Image:"' & GUICtrlRead($T12Input1) & '" /Get-ProvisionedAppxPackages', 0)
            ElseIf GUICtrlRead($T12Checkbox1) = $Gui_Checked Then
                _GET_PROVISIONEDAPPXPACKAGES(@ComSpec & ' /c Dism.exe /Online /Get-ProvisionedAppxPackages', 1)
            EndIf
    EndSwitch
EndFunc   ;==>_Tab_12

Func _GET_PROVISIONEDAPPXPACKAGES($sDISM_PARAMETERS, $iDISM_ONLINEMODE = 0)
    Local $aGET_PROVISIONEDAPPXPACKAGES[0][5], $hRUN_PROVISIONEDAPPXPACKAGES
    If @OSArch = 'x64' Then
        DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 1) ;~ Turn On 64 Bit Redirection
            $hRUN_PROVISIONEDAPPXPACKAGES = Run($sDISM_PARAMETERS, '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
        DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 0) ;~ Turn Off 64 Bit Redirection
    Else
        $hRUN_PROVISIONEDAPPXPACKAGES = Run($sDISM_PARAMETERS, '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
    EndIf
    ProcessWaitClose($hRUN_PROVISIONEDAPPXPACKAGES)
    $sRUN_PROVISIONEDAPPXPACKAGES = StdoutRead($hRUN_PROVISIONEDAPPXPACKAGES)
    $aRUN_PROVISIONEDAPPXPACKAGES = StringSplit($sRUN_PROVISIONEDAPPXPACKAGES, @CR)
    For $x = 1 To $aRUN_PROVISIONEDAPPXPACKAGES[0]
        If StringInStr($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'DisplayName : ') Then
            ReDim $aGET_PROVISIONEDAPPXPACKAGES[UBound($aGET_PROVISIONEDAPPXPACKAGES) + 1][5]
            $aGET_PROVISIONEDAPPXPACKAGES[UBound($aGET_PROVISIONEDAPPXPACKAGES) - 1][0] = StringReplace($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'DisplayName : ', '')
        EndIf
        If StringInStr($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'Version : ') Then
            $aGET_PROVISIONEDAPPXPACKAGES[UBound($aGET_PROVISIONEDAPPXPACKAGES) - 1][1] = StringReplace($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'Version : ', '')
        EndIf
        If StringInStr($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'Architecture : ') Then
            $aGET_PROVISIONEDAPPXPACKAGES[UBound($aGET_PROVISIONEDAPPXPACKAGES) - 1][2] = StringReplace($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'Architecture : ', '')
        EndIf
        If StringInStr($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'ResourceId : ') Then
            $aGET_PROVISIONEDAPPXPACKAGES[UBound($aGET_PROVISIONEDAPPXPACKAGES) - 1][3] = StringReplace($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'ResourceId : ', '')
        EndIf
        If StringInStr($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'PackageName :') Then
            $aGET_PROVISIONEDAPPXPACKAGES[UBound($aGET_PROVISIONEDAPPXPACKAGES) - 1][4] = StringReplace($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'PackageName : ', '')
        EndIf
    Next
    Local $hGUI_PROVISIONEDAPPXPACKAGES = GUICreate('Get PackagexApps', 600, 600, -1, -1, -1, -1, $Form1)
    $hGUI_LISTVIEW = GUICtrlCreateListView('Display Name|Version|Architecture|ResourceId|Package Name', 5, 5, 590, 555, -1, BitOR($LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES))
    _GUICtrlListView_AddArray($hGUI_LISTVIEW, $aGET_PROVISIONEDAPPXPACKAGES)
    _GUICtrlListView_SetColumnWidth($hGUI_LISTVIEW, 0, 250)
    $hBTN_CLOSEGUI = GUICtrlCreateButton('Cancel', 290, 565, 150, 30)
    $hBTN_REMOVEAPP = GUICtrlCreateButton('Remove Packages', 445, 565, 150, 30)
    GUISetState(@SW_SHOW, $hGUI_PROVISIONEDAPPXPACKAGES)
    While 1
        $iPKG = GUIGetMsg()
        Switch $iPKG
            Case $GUI_EVENT_CLOSE, $hBTN_CLOSEGUI
                ExitLoop
            Case $hBTN_REMOVEAPP
                $iGUI_LISTVIEW = _GUICtrlListView_GetItemCount($hGUI_LISTVIEW)
                If $iGUI_LISTVIEW > 0 Then
                    For $i = $iGUI_LISTVIEW To 0 Step - 1
                        If _GUICtrlListView_GetItemChecked($hGUI_LISTVIEW, $i) Then
                            Switch $iDISM_ONLINEMODE
                                Case 0
                                    MsgBox(0,'', 'Run(' & @ComSpec & ' /c "' & @ScriptDir & '\Dism.exe" /Image:"' & GUICtrlRead($T12Input1) & '" /Remove-ProvisionedAppxPackage /PackageName:' & $aGET_PROVISIONEDAPPXPACKAGES[$i][4])
                                    _GUICtrlListView_DeleteItem($hGUI_LISTVIEW, $i)
                                Case 1
                                    MsgBox(0,'', 'Run(' & @ComSpec & ' /c "' & @ScriptDir & '\Dism.exe" /Online /Remove-ProvisionedAppxPackage /PackageName:' & $aGET_PROVISIONEDAPPXPACKAGES[$i][4])
                                    _GUICtrlListView_DeleteItem($hGUI_LISTVIEW, $i)
                            EndSwitch
                        EndIf
                    Next
                EndIf
        EndSwitch
    WEnd
    GUIDelete($hGUI_PROVISIONEDAPPXPACKAGES)
EndFunc

 

Link to comment
Share on other sites

@Subz This looks awesome, my coding skills are so basic I could never do anything like it!

My initial test on a 8.1 mounted image show it failed to remove anything. As far as adding App Pkgs I don't think most users require the function and wasn't planning on pursuing it any further unless requested.

PS: Take your time I'm in no hurry. I have another form design made some room and added a couple buttons I was just waiting for your input.

@careca That looks like something  I can deal with. Short, sweet and easy to understand. Let me see what I can do with it.

Link to comment
Share on other sites

@trashy No problem, in the code above I just used a MsgBox to show what command it would normally issue i.e. so when you tested did you replace:

Case 0
    MsgBox(0,'', 'Run(' & @ComSpec & ' /c "' & @ScriptDir & '\Dism.exe" /Image:"' & GUICtrlRead($T12Input1) & '" /Remove-ProvisionedAppxPackage /PackageName:' & $aGET_PROVISIONEDAPPXPACKAGES[$i][4])
    _GUICtrlListView_DeleteItem($hGUI_LISTVIEW, $i)
Case 1
    MsgBox(0,'', 'Run(' & @ComSpec & ' /c "' & @ScriptDir & '\Dism.exe" /Online /Remove-ProvisionedAppxPackage /PackageName:' & $aGET_PROVISIONEDAPPXPACKAGES[$i][4])
    _GUICtrlListView_DeleteItem($hGUI_LISTVIEW, $i)

With

Case 0
    If @OSArch = 'x64' Then
        DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 1) ;~ Turn On 64 Bit Redirection
            Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe" /Image:"' & GUICtrlRead($T12Input1) & '" /Remove-ProvisionedAppxPackage /PackageName:' & $aGET_PROVISIONEDAPPXPACKAGES[$i][4])
        DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 0) ;~ Turn Off 64 Bit Redirection
    Else
        Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe" /Image:"' & GUICtrlRead($T12Input1) & '" /Remove-ProvisionedAppxPackage /PackageName:' & $aGET_PROVISIONEDAPPXPACKAGES[$i][4])
    EndIf
    _GUICtrlListView_DeleteItem($hGUI_LISTVIEW, $i)
Case 1
    If @OSArch = 'x64' Then
        DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 1) ;~ Turn On 64 Bit Redirection
            Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe" /Online /Remove-ProvisionedAppxPackage /PackageName:' & $aGET_PROVISIONEDAPPXPACKAGES[$i][4])
        DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 0) ;~ Turn Off 64 Bit Redirection
    Else
        Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe" /Online /Remove-ProvisionedAppxPackage /PackageName:' & $aGET_PROVISIONEDAPPXPACKAGES[$i][4])
    EndIf
    _GUICtrlListView_DeleteItem($hGUI_LISTVIEW, $i)

 

Edited by Subz
Updated Running in x64/x86 Mode
Link to comment
Share on other sites

@Subz I made a few tweaks to your DISM cmd line from my experience this should work but getting an error.

The /PackageName: option is missing a required argument.

Run(@ComSpec & ' /k "' & @ScriptDir & '\Dism.exe /Image:"' & GUICtrlRead($T12Input1) & '" /Remove-ProvisionedAppxPackage /PackageName:"' & $aGET_PROVISIONEDAPPXPACKAGES[$i][4] & '""', '', @SW_SHOW)

Below is the whole tab and if this works would be awesome!

#RequireAdmin
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <GuiTab.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>
#include <Constants.au3>
#include <Process.au3>
#include <ComboConstants.au3>
#include <WinAPIDlg.au3>
#include <GuiListView.au3>
#include <ColorConstants.au3>
#include <Array.au3>
#include <String.au3>
#include <FontConstants.au3.>
#include <GuiEdit.au3>
#include <ScrollBarsConstants.au3>
#include <GuiStatusBar.au3>
#include <File.au3>

$Form1 = GUICreate("Easy_DISM", 620, 680, -1, -1, -1, BitOR($WS_EX_WINDOWEDGE, $TCS_TOOLTIPS))

$c = ' /c '
$dismon = '\Dism.exe /Online"'
$miInfo = '\Dism.exe /Get-MountedImageInfo"'

$Tab1 = GUICtrlCreateTab(24, -1, 570, 600, BitOR($TCS_MULTILINE, $TCS_FLATBUTTONS))

;Start AppPkg Tab
$TabSheet12 = GUICtrlCreateTabItem("AppPkg")
$iStart_12 = GUICtrlCreateDummy() ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$T12Checkbox1 = GUICtrlCreateCheckbox("Online", 504, 80, 60, 17)
$T12Button1 = GUICtrlCreateButton("Browse", 504, 48, 75, 25)
$T12Button2 = GUICtrlCreateButton("Browse", 416, 298, 75, 25)
$T12Button3 = GUICtrlCreateButton("ADD", 504, 298, 75, 25)
$T12Button4 = GUICtrlCreateButton("Browse", 416, 325, 75, 25)
$T12Button5 = GUICtrlCreateButton("ADD", 504, 325, 75, 25)
$T12Button6 = GUICtrlCreateButton("Remove", 504, 352, 75, 25)
$T12Button8 = GUICtrlCreateButton("AppPkg Info", 504, 440, 75, 25)
$T12Edit1 = GUICtrlCreateEdit("", 120, 80, 370, 210, $ES_READONLY + $WS_VSCROLL + $WS_HSCROLL)
GUICtrlSetData(-1, "")
$T12Edit2 = GUICtrlCreateEdit("", 120, 380, 370, 210, $ES_READONLY + $WS_VSCROLL + $WS_HSCROLL)
GUICtrlSetData(-1, @CRLF & "Remove AppPkg: Select Online or Mount Folder" & @CRLF & "Click Remove Button and select the Apps you wish to remove" & @CRLF & @CRLF & "ADD App Package UNTESTED")
$T12Input1 = GUICtrlCreateInput("", 120, 48, 370, 21)
$T12Input2 = GUICtrlCreateInput("Used /SkipLicense option (error License required)", 120, 298, 281, 21)
$T12Input3 = GUICtrlCreateInput("Un Tested", 120, 325, 281, 21)
$T12Input4 = GUICtrlCreateInput("Click Remove and check Pkgs to be removed", 120, 352, 370, 21)
$T12Label1 = GUICtrlCreateLabel("Mount Folder", 45, 48, 62, 17)
$T12Label2 = GUICtrlCreateLabel("Single AppPkg", 45, 298, 70, 17)
$T12Label3 = GUICtrlCreateLabel("AppPkg Folder", 45, 325, 70, 17)
$T12Label4 = GUICtrlCreateLabel("Remove Apps", 45, 352, 70, 17)
$iEnd_12 = GUICtrlCreateDummy() ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

GUICtrlCreateTabItem("")
$Button1 = GUICtrlCreateButton("EXIT", 272, 650, 75, 25)
$progress = GUICtrlCreateEdit("", 120, 600, 380, 50, $ES_READONLY)
GUISetState(@SW_SHOW, $Form1)

$Run = Run(@ComSpec & $c & @ScriptDir & $miInfo, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
ProcessWaitClose($Run, 2)
$data = StdoutRead($Run)
GUICtrlSetData($T12Edit1, $data)
;GUICtrlSetData($T2Edit1, $data)
;GUICtrlSetData($T3Edit1, $data)
;GUICtrlSetData($T4Edit1, $data)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            Exit
        Case $iStart_12 To $iEnd_12
            _Tab_12($nMsg)

    EndSwitch
WEnd

Func _Tab_12($nMsg) ;<<<<< AppPkg Tab
    Switch $nMsg
        Case $T12Checkbox1
            If GUICtrlRead($T12Checkbox1) = $Gui_Checked Then
                GUICtrlSetState($T12Input1, $GUI_DISABLE)
                GUICtrlSetState($T12Button1, $GUI_DISABLE)
            ElseIf GUICtrlRead($T12Checkbox1) = $Gui_UnChecked Then
                GUICtrlSetState($T12Input1, $GUI_ENABLE)
                GUICtrlSetState($T12Button1, $GUI_ENABLE)
            EndIf
        Case $T12Button1
            $of_T3Button1 = FileSelectFolder("Select Mount Folder: ", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", 4)
            GUICtrlSetData($T12Input1, $of_T3Button1)
            $aRun = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Get-MountedImageInfo"', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
            ProcessWaitClose($aRun, 0)
            $adata = StdoutRead($aRun)
            GUICtrlSetData($T12Edit1, $adata)
        Case $T12Button2
            $of_T3Button2 = FileOpenDialog("Select Pkg File", @HomeDrive, "AppPkg Files (*.appx;*.appxbundle)", 1 + 4, "")
            GUICtrlSetData($T12Input2, $of_T3Button2)
        Case $T12Button3
            If GUICtrlRead($T12Checkbox1) = $Gui_UnChecked Then
                If GUICtrlRead($T12Input1) = "" Then
                    MsgBox(262144, "Empty.....", "No Mount Folder Selected!")
                    Return
                EndIf
                If GUICtrlRead($T12Input2) = "" Then
                    MsgBox(262144, "Empty.....", "No AppPkg Selected!")
                    Return
                EndIf
                $output = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Image:"' & GUICtrlRead($T12Input1) & '" /Add-ProvisionedAppxPackage /PackagePath:"' & GUICtrlRead($T12Input2) & '" /SkipLicense"', '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($output)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($progress, $progout)
                        _GUICtrlEdit_Scroll($progress, $SB_SCROLLCARET)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            ElseIf GUICtrlRead($T12Checkbox1) = $Gui_Checked Then
                If GUICtrlRead($T12Input2) = "" Then
                    MsgBox(262144, "Empty.....", "No AppPkg Selected!")
                    Return
                EndIf
                $output = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Online /Add-ProvisionedAppxPackage /PackagePath:"' & GUICtrlRead($T12Input2) & '" /SkipLicense"', '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($output)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($progress, $progout)
                        _GUICtrlEdit_Scroll($progress, $SB_SCROLLCARET)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            EndIf
        Case $T12Button4
            $of_T3Button4 = FileSelectFolder("Select Pkg : ", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", 4)
            GUICtrlSetData($T12Input3, $of_T3Button4)
        Case $T12Button5
            If GUICtrlRead($T12Checkbox1) = $Gui_UnChecked Then
                If GUICtrlRead($T12Input1) = "" Then
                    MsgBox(262144, "Empty.....", "No Mount Folder Selected!")
                    Return
                EndIf
                If GUICtrlRead($T12Input3) = "" Then
                    MsgBox(262144, "Empty.....", "No AppPkg Folder Selected!")
                    Return
                EndIf
                $output = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Image:"' & GUICtrlRead($T12Input1) & '" /Add-ProvisionedAppxPackage /FolderPath:"' & GUICtrlRead($T12Input3) & '""', '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($output)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($progress, $progout)
                        _GUICtrlEdit_Scroll($progress, $SB_SCROLLCARET)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            ElseIf GUICtrlRead($T12Checkbox1) = $Gui_Checked Then
                If GUICtrlRead($T12Input3) = "" Then
                    MsgBox(262144, "Empty.....", "No AppPkg Folder Selected!")
                    Return
                EndIf
                $output = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Online /Add-ProvisionedAppxPackage /FolderPath:"' & GUICtrlRead($T12Input3) & '""', '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($output)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($progress, $progout)
                        _GUICtrlEdit_Scroll($progress, $SB_SCROLLCARET)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            EndIf
        Case $T12Button6
            If GUICtrlRead($T12Checkbox1) = $Gui_UnChecked Then
                If GUICtrlRead($T12Input1) = "" Then
                    MsgBox(262144, "Empty.....", "No Mount Folder Selected!")
                    Return
                EndIf

                _GET_PROVISIONEDAPPXPACKAGES(@ComSpec & ' /c Dism.exe /Image:"' & GUICtrlRead($T12Input1) & '" /Get-ProvisionedAppxPackages', 0)
            ElseIf GUICtrlRead($T12Checkbox1) = $Gui_Checked Then
                _GET_PROVISIONEDAPPXPACKAGES(@ComSpec & ' /c Dism.exe /Online /Get-ProvisionedAppxPackages', 1)

            EndIf
        Case $T12Button8
            If GUICtrlRead($T12Checkbox1) = $Gui_UnChecked Then
                If GUICtrlRead($T12Input1) = "" Then
                    MsgBox(262144, "Empty.....", "No Mount Folder Selected!")
                    Return
                EndIf
                $bRun = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Image:"' & GUICtrlRead($T12Input1) & '" /Get-ProvisionedAppxPackages"', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($bRun)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($T12Edit2, $progout)
                        _GUICtrlEdit_Scroll($T12Edit2, $SB_SCROLLCARET)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            ElseIf GUICtrlRead($T12Checkbox1) = $Gui_Checked Then
                $bRun = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Online /Get-ProvisionedAppxPackages"', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($bRun)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($T12Edit2, $progout)
                        _GUICtrlEdit_Scroll($T12Edit2, $SB_SCROLLCARET)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            EndIf
    EndSwitch
EndFunc   ;==>_Tab_12

Func _GET_PROVISIONEDAPPXPACKAGES($sDISM_PARAMETERS, $iDISM_ONLINEMODE = 0)
    Local $aGET_PROVISIONEDAPPXPACKAGES[0][5], $hRUN_PROVISIONEDAPPXPACKAGES
    If @OSArch = 'x64' Then
        DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 1) ;~ Turn On 64 Bit Redirection
        $hRUN_PROVISIONEDAPPXPACKAGES = Run($sDISM_PARAMETERS, '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
        DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 0) ;~ Turn Off 64 Bit Redirection
    Else
        $hRUN_PROVISIONEDAPPXPACKAGES = Run($sDISM_PARAMETERS, '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
    EndIf
    ProcessWaitClose($hRUN_PROVISIONEDAPPXPACKAGES)
    $sRUN_PROVISIONEDAPPXPACKAGES = StdoutRead($hRUN_PROVISIONEDAPPXPACKAGES)
    $aRUN_PROVISIONEDAPPXPACKAGES = StringSplit($sRUN_PROVISIONEDAPPXPACKAGES, @CR)
    For $x = 1 To $aRUN_PROVISIONEDAPPXPACKAGES[0]
        If StringInStr($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'DisplayName : ') Then
            ReDim $aGET_PROVISIONEDAPPXPACKAGES[UBound($aGET_PROVISIONEDAPPXPACKAGES) + 1][5]
            $aGET_PROVISIONEDAPPXPACKAGES[UBound($aGET_PROVISIONEDAPPXPACKAGES) - 1][0] = StringReplace($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'DisplayName : ', '')
        EndIf
        If StringInStr($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'Version : ') Then
            $aGET_PROVISIONEDAPPXPACKAGES[UBound($aGET_PROVISIONEDAPPXPACKAGES) - 1][1] = StringReplace($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'Version : ', '')
        EndIf
        If StringInStr($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'Architecture : ') Then
            $aGET_PROVISIONEDAPPXPACKAGES[UBound($aGET_PROVISIONEDAPPXPACKAGES) - 1][2] = StringReplace($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'Architecture : ', '')
        EndIf
        If StringInStr($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'ResourceId : ') Then
            $aGET_PROVISIONEDAPPXPACKAGES[UBound($aGET_PROVISIONEDAPPXPACKAGES) - 1][3] = StringReplace($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'ResourceId : ', '')
        EndIf
        If StringInStr($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'PackageName :') Then
            $aGET_PROVISIONEDAPPXPACKAGES[UBound($aGET_PROVISIONEDAPPXPACKAGES) - 1][4] = StringReplace($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'PackageName : ', '')
        EndIf
    Next
    Local $hGUI_PROVISIONEDAPPXPACKAGES = GUICreate('Get PackagexApps', 600, 600, -1, -1, -1, -1, $Form1)
    $hGUI_LISTVIEW = GUICtrlCreateListView('Display Name|Version|Architecture|ResourceId|Package Name', 5, 5, 590, 555, -1, BitOR($LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES))
    _GUICtrlListView_AddArray($hGUI_LISTVIEW, $aGET_PROVISIONEDAPPXPACKAGES)
    _GUICtrlListView_SetColumnWidth($hGUI_LISTVIEW, 0, 250)
    $hBTN_CLOSEGUI = GUICtrlCreateButton('Cancel', 290, 565, 150, 30)
    $hBTN_REMOVEAPP = GUICtrlCreateButton('Remove Packages', 445, 565, 150, 30)
    GUISetState(@SW_SHOW, $hGUI_PROVISIONEDAPPXPACKAGES)
    While 1
        $iPKG = GUIGetMsg()
        Switch $iPKG
            Case $GUI_EVENT_CLOSE, $hBTN_CLOSEGUI
                ExitLoop
            Case $hBTN_REMOVEAPP
                $iGUI_LISTVIEW = _GUICtrlListView_GetItemCount($hGUI_LISTVIEW)
                If $iGUI_LISTVIEW > 0 Then
                    For $i = $iGUI_LISTVIEW To 0 Step -1
                        If _GUICtrlListView_GetItemChecked($hGUI_LISTVIEW, $i) Then
                            Switch $iDISM_ONLINEMODE
                                Case 0
                                    If @OSArch = 'x64' Then
                                        DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 1) ;~ Turn On 64 Bit Redirection
                                        Run(@ComSpec & ' /k "' & @ScriptDir & '\Dism.exe /Image:"' & GUICtrlRead($T12Input1) & '" /Remove-ProvisionedAppxPackage /PackageName:"' & $aGET_PROVISIONEDAPPXPACKAGES[$i][4] & '""', '', @SW_SHOW)
                                        DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 0) ;~ Turn Off 64 Bit Redirection
                                    Else
                                        Run(@ComSpec & ' /k "' & @ScriptDir & '\Dism.exe /Image:"' & GUICtrlRead($T12Input1) & '" /Remove-ProvisionedAppxPackage /PackageName:"' & $aGET_PROVISIONEDAPPXPACKAGES[$i][4] & '""', '', @SW_SHOW)
                                    EndIf
                                    _GUICtrlListView_DeleteItem($hGUI_LISTVIEW, $i)
                                Case 1
                                    If @OSArch = 'x64' Then
                                        DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 1) ;~ Turn On 64 Bit Redirection
                                        Run(@ComSpec & ' /k "' & @ScriptDir & '\Dism.exe /Online /Remove-ProvisionedAppxPackage /PackageName:"' & $aGET_PROVISIONEDAPPXPACKAGES[$i][4] & '""', '', @SW_SHOW)
                                        DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 0) ;~ Turn Off 64 Bit Redirection
                                    Else
                                        Run(@ComSpec & ' /k "' & @ScriptDir & '\Dism.exe /Online /Remove-ProvisionedAppxPackage /PackageName:"' & $aGET_PROVISIONEDAPPXPACKAGES[$i][4] & '""', '', @SW_SHOW)
                                    EndIf
                                    _GUICtrlListView_DeleteItem($hGUI_LISTVIEW, $i)
                            EndSwitch
                        EndIf
                    Next
                EndIf
        EndSwitch
    WEnd
    GUIDelete($hGUI_PROVISIONEDAPPXPACKAGES)
EndFunc   ;==>_GET_PROVISIONEDAPPXPACKAGES

 

Link to comment
Share on other sites

Sorry my bad the ListView Item includes an EOL character so just added StringStripWS with flag 7 and everything is working again.

Also added another function _GET_DISMPATH()

This will look for Dism in the default location C:\Windows\System32\Dism.exe

If it's not found it will ask to browse to the location where Dism.exe is located, it then writes this to EasyDism.ini for future reference it then adds EnvSet to that Path, that way you can just use the command: @ComSpec & ' /c Dism.exe /....'  If the user doesn't have Dism and cancels it will give them the link to Windows Assessment and Deployment Kit so they can install.  If its a network environment and you have Windows Assessment and Deployment Kit saved to a Shared folder you can add the following to EasyDism.ini

[General]
Dism Install = \\Server\Share

When the user clicks on the link they will be taken to the share.

Hope that makes sense, its what I used in my tool since Windows Assessment and Deployment Kit is kind of a large download.

#RequireAdmin
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <GuiTab.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>
#include <Constants.au3>
#include <Process.au3>
#include <ComboConstants.au3>
#include <WinAPIDlg.au3>
#include <GuiListView.au3>
#include <ColorConstants.au3>
#include <Array.au3>
#include <String.au3>
#include <FontConstants.au3.>
#include <GuiEdit.au3>
#include <ScrollBarsConstants.au3>
#include <GuiStatusBar.au3>
#include <File.au3>

Opt('ExpandVarStrings', 1)
Global $sINI_EASYDISM = '@ScriptDir@\EasyDism.ini'
_GET_DISMPATH()

$Form1 = GUICreate("Easy_DISM", 620, 680, -1, -1, -1, BitOR($WS_EX_WINDOWEDGE, $TCS_TOOLTIPS))

$c = ' /c '
$dismon = '\Dism.exe /Online"'
$miInfo = '\Dism.exe /Get-MountedImageInfo"'

$Tab1 = GUICtrlCreateTab(24, -1, 570, 600, BitOR($TCS_MULTILINE, $TCS_FLATBUTTONS))

;Start AppPkg Tab
$TabSheet12 = GUICtrlCreateTabItem("AppPkg")
$iStart_12 = GUICtrlCreateDummy() ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$T12Checkbox1 = GUICtrlCreateCheckbox("Online", 504, 80, 60, 17)
$T12Button1 = GUICtrlCreateButton("Browse", 504, 48, 75, 25)
$T12Button2 = GUICtrlCreateButton("Browse", 416, 298, 75, 25)
$T12Button3 = GUICtrlCreateButton("ADD", 504, 298, 75, 25)
$T12Button4 = GUICtrlCreateButton("Browse", 416, 325, 75, 25)
$T12Button5 = GUICtrlCreateButton("ADD", 504, 325, 75, 25)
$T12Button6 = GUICtrlCreateButton("Remove", 504, 352, 75, 25)
$T12Button8 = GUICtrlCreateButton("AppPkg Info", 504, 440, 75, 25)
$T12Edit1 = GUICtrlCreateEdit("", 120, 80, 370, 210, $ES_READONLY + $WS_VSCROLL + $WS_HSCROLL)
GUICtrlSetData(-1, "")
$T12Edit2 = GUICtrlCreateEdit("", 120, 380, 370, 210, $ES_READONLY + $WS_VSCROLL + $WS_HSCROLL)
GUICtrlSetData(-1, @CRLF & "Remove AppPkg: Select Online or Mount Folder" & @CRLF & "Click Remove Button and select the Apps you wish to remove" & @CRLF & @CRLF & "ADD App Package UNTESTED")
$T12Input1 = GUICtrlCreateInput("", 120, 48, 370, 21)
$T12Input2 = GUICtrlCreateInput("Used /SkipLicense option (error License required)", 120, 298, 281, 21)
$T12Input3 = GUICtrlCreateInput("Un Tested", 120, 325, 281, 21)
$T12Input4 = GUICtrlCreateInput("Click Remove and check Pkgs to be removed", 120, 352, 370, 21)
$T12Label1 = GUICtrlCreateLabel("Mount Folder", 45, 48, 62, 17)
$T12Label2 = GUICtrlCreateLabel("Single AppPkg", 45, 298, 70, 17)
$T12Label3 = GUICtrlCreateLabel("AppPkg Folder", 45, 325, 70, 17)
$T12Label4 = GUICtrlCreateLabel("Remove Apps", 45, 352, 70, 17)
$iEnd_12 = GUICtrlCreateDummy() ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

GUICtrlCreateTabItem("")
$Button1 = GUICtrlCreateButton("EXIT", 272, 650, 75, 25)
$progress = GUICtrlCreateEdit("", 120, 600, 380, 50, $ES_READONLY)
GUISetState(@SW_SHOW, $Form1)

$Run = Run(@ComSpec & $c & @ScriptDir & $miInfo, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
ProcessWaitClose($Run, 2)
$data = StdoutRead($Run)
GUICtrlSetData($T12Edit1, $data)
;GUICtrlSetData($T2Edit1, $data)
;GUICtrlSetData($T3Edit1, $data)
;GUICtrlSetData($T4Edit1, $data)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            Exit
        Case $iStart_12 To $iEnd_12
            _Tab_12($nMsg)

    EndSwitch
WEnd

Func _Tab_12($nMsg) ;<<<<< AppPkg Tab
    Switch $nMsg
        Case $T12Checkbox1
            If GUICtrlRead($T12Checkbox1) = $Gui_Checked Then
                GUICtrlSetState($T12Input1, $GUI_DISABLE)
                GUICtrlSetState($T12Button1, $GUI_DISABLE)
            ElseIf GUICtrlRead($T12Checkbox1) = $Gui_UnChecked Then
                GUICtrlSetState($T12Input1, $GUI_ENABLE)
                GUICtrlSetState($T12Button1, $GUI_ENABLE)
            EndIf
        Case $T12Button1
            $of_T3Button1 = FileSelectFolder("Select Mount Folder: ", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", 4)
            GUICtrlSetData($T12Input1, $of_T3Button1)
            $aRun = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Get-MountedImageInfo"', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
            ProcessWaitClose($aRun, 0)
            $adata = StdoutRead($aRun)
            GUICtrlSetData($T12Edit1, $adata)
        Case $T12Button2
            $of_T3Button2 = FileOpenDialog("Select Pkg File", @HomeDrive, "AppPkg Files (*.appx;*.appxbundle)", 1 + 4, "")
            GUICtrlSetData($T12Input2, $of_T3Button2)
        Case $T12Button3
            If GUICtrlRead($T12Checkbox1) = $Gui_UnChecked Then
                If GUICtrlRead($T12Input1) = "" Then
                    MsgBox(262144, "Empty.....", "No Mount Folder Selected!")
                    Return
                EndIf
                If GUICtrlRead($T12Input2) = "" Then
                    MsgBox(262144, "Empty.....", "No AppPkg Selected!")
                    Return
                EndIf
                $output = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Image:"' & GUICtrlRead($T12Input1) & '" /Add-ProvisionedAppxPackage /PackagePath:"' & GUICtrlRead($T12Input2) & '" /SkipLicense"', '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($output)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($progress, $progout)
                        _GUICtrlEdit_Scroll($progress, $SB_SCROLLCARET)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            ElseIf GUICtrlRead($T12Checkbox1) = $Gui_Checked Then
                If GUICtrlRead($T12Input2) = "" Then
                    MsgBox(262144, "Empty.....", "No AppPkg Selected!")
                    Return
                EndIf
                $output = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Online /Add-ProvisionedAppxPackage /PackagePath:"' & GUICtrlRead($T12Input2) & '" /SkipLicense"', '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($output)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($progress, $progout)
                        _GUICtrlEdit_Scroll($progress, $SB_SCROLLCARET)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            EndIf
        Case $T12Button4
            $of_T3Button4 = FileSelectFolder("Select Pkg : ", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", 4)
            GUICtrlSetData($T12Input3, $of_T3Button4)
        Case $T12Button5
            If GUICtrlRead($T12Checkbox1) = $Gui_UnChecked Then
                If GUICtrlRead($T12Input1) = "" Then
                    MsgBox(262144, "Empty.....", "No Mount Folder Selected!")
                    Return
                EndIf
                If GUICtrlRead($T12Input3) = "" Then
                    MsgBox(262144, "Empty.....", "No AppPkg Folder Selected!")
                    Return
                EndIf
                $output = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Image:"' & GUICtrlRead($T12Input1) & '" /Add-ProvisionedAppxPackage /FolderPath:"' & GUICtrlRead($T12Input3) & '""', '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($output)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($progress, $progout)
                        _GUICtrlEdit_Scroll($progress, $SB_SCROLLCARET)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            ElseIf GUICtrlRead($T12Checkbox1) = $Gui_Checked Then
                If GUICtrlRead($T12Input3) = "" Then
                    MsgBox(262144, "Empty.....", "No AppPkg Folder Selected!")
                    Return
                EndIf
                $output = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Online /Add-ProvisionedAppxPackage /FolderPath:"' & GUICtrlRead($T12Input3) & '""', '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($output)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($progress, $progout)
                        _GUICtrlEdit_Scroll($progress, $SB_SCROLLCARET)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            EndIf
        Case $T12Button6
            If GUICtrlRead($T12Checkbox1) = $Gui_UnChecked Then
                If GUICtrlRead($T12Input1) = "" Then
                    MsgBox(262144, "Empty.....", "No Mount Folder Selected!")
                    Return
                EndIf

                _GET_PROVISIONEDAPPXPACKAGES(@ComSpec & ' /c Dism.exe /Image:"' & GUICtrlRead($T12Input1) & '" /Get-ProvisionedAppxPackages', 0)
            ElseIf GUICtrlRead($T12Checkbox1) = $Gui_Checked Then
                _GET_PROVISIONEDAPPXPACKAGES(@ComSpec & ' /c Dism.exe /Online /Get-ProvisionedAppxPackages', 1)

            EndIf
        Case $T12Button8
            If GUICtrlRead($T12Checkbox1) = $Gui_UnChecked Then
                If GUICtrlRead($T12Input1) = "" Then
                    MsgBox(262144, "Empty.....", "No Mount Folder Selected!")
                    Return
                EndIf
                $bRun = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Image:"' & GUICtrlRead($T12Input1) & '" /Get-ProvisionedAppxPackages"', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($bRun)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($T12Edit2, $progout)
                        _GUICtrlEdit_Scroll($T12Edit2, $SB_SCROLLCARET)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            ElseIf GUICtrlRead($T12Checkbox1) = $Gui_Checked Then
                $bRun = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Online /Get-ProvisionedAppxPackages"', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($bRun)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($T12Edit2, $progout)
                        _GUICtrlEdit_Scroll($T12Edit2, $SB_SCROLLCARET)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            EndIf
    EndSwitch
EndFunc   ;==>_Tab_12

Func _GET_PROVISIONEDAPPXPACKAGES($sDISM_PARAMETERS, $iDISM_ONLINEMODE = 0)
    Local $aGET_PROVISIONEDAPPXPACKAGES[0][5], $hRUN_PROVISIONEDAPPXPACKAGES
    If @OSArch = 'x64' Then
        DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 1) ;~ Turn On 64 Bit Redirection
        $hRUN_PROVISIONEDAPPXPACKAGES = Run($sDISM_PARAMETERS, '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
        DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 0) ;~ Turn Off 64 Bit Redirection
    Else
        $hRUN_PROVISIONEDAPPXPACKAGES = Run($sDISM_PARAMETERS, '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
    EndIf
    ProcessWaitClose($hRUN_PROVISIONEDAPPXPACKAGES)
    $sRUN_PROVISIONEDAPPXPACKAGES = StdoutRead($hRUN_PROVISIONEDAPPXPACKAGES)
    $aRUN_PROVISIONEDAPPXPACKAGES = StringSplit($sRUN_PROVISIONEDAPPXPACKAGES, @CR)
    For $x = 1 To $aRUN_PROVISIONEDAPPXPACKAGES[0]
        If StringInStr($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'DisplayName : ') Then
            ReDim $aGET_PROVISIONEDAPPXPACKAGES[UBound($aGET_PROVISIONEDAPPXPACKAGES) + 1][5]
            $aGET_PROVISIONEDAPPXPACKAGES[UBound($aGET_PROVISIONEDAPPXPACKAGES) - 1][0] = StringStripWS(StringReplace($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'DisplayName : ', ''), 7)
        EndIf
        If StringInStr($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'Version : ') Then
            $aGET_PROVISIONEDAPPXPACKAGES[UBound($aGET_PROVISIONEDAPPXPACKAGES) - 1][1] = StringStripWS(StringReplace($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'Version : ', ''), 7)
        EndIf
        If StringInStr($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'Architecture : ') Then
            $aGET_PROVISIONEDAPPXPACKAGES[UBound($aGET_PROVISIONEDAPPXPACKAGES) - 1][2] = StringStripWS(StringReplace($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'Architecture : ', ''), 7)
        EndIf
        If StringInStr($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'ResourceId : ') Then
            $aGET_PROVISIONEDAPPXPACKAGES[UBound($aGET_PROVISIONEDAPPXPACKAGES) - 1][3] = StringStripWS(StringReplace($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'ResourceId : ', ''), 7)
        EndIf
        If StringInStr($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'PackageName :') Then
            $aGET_PROVISIONEDAPPXPACKAGES[UBound($aGET_PROVISIONEDAPPXPACKAGES) - 1][4] = StringStripWS(StringReplace($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'PackageName : ', ''), 7)
        EndIf
    Next
    Local $hGUI_PROVISIONEDAPPXPACKAGES = GUICreate('Get PackagexApps', 600, 600, -1, -1, -1, -1, $Form1)
    $hGUI_LISTVIEW = GUICtrlCreateListView('Display Name|Version|Architecture|ResourceId|Package Name', 5, 5, 590, 555, -1, BitOR($LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES))
    _GUICtrlListView_AddArray($hGUI_LISTVIEW, $aGET_PROVISIONEDAPPXPACKAGES)
    _GUICtrlListView_SetColumnWidth($hGUI_LISTVIEW, 0, 250)
    $hBTN_CLOSEGUI = GUICtrlCreateButton('Cancel', 290, 565, 150, 30)
    $hBTN_REMOVEAPP = GUICtrlCreateButton('Remove Packages', 445, 565, 150, 30)
    GUISetState(@SW_SHOW, $hGUI_PROVISIONEDAPPXPACKAGES)
    While 1
        $iPKG = GUIGetMsg()
        Switch $iPKG
            Case $GUI_EVENT_CLOSE, $hBTN_CLOSEGUI
                ExitLoop
            Case $hBTN_REMOVEAPP
                $iGUI_LISTVIEW = _GUICtrlListView_GetItemCount($hGUI_LISTVIEW)
                If $iGUI_LISTVIEW > 0 Then
                    For $i = $iGUI_LISTVIEW To 0 Step -1
                        If _GUICtrlListView_GetItemChecked($hGUI_LISTVIEW, $i) Then
                            Switch $iDISM_ONLINEMODE
                                Case 0
                                    If @OSArch = 'x64' Then
                                        DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 1) ;~ Turn On 64 Bit Redirection
                                        Run(@ComSpec & ' /k Dism.exe /Image:"' & GUICtrlRead($T12Input1) & '" /Remove-ProvisionedAppxPackage /PackageName:' & $aGET_PROVISIONEDAPPXPACKAGES[$i][4])
                                        DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 0) ;~ Turn Off 64 Bit Redirection
                                    Else
                                        Run(@ComSpec & ' /k Dism.exe /Image:"' & GUICtrlRead($T12Input1) & '" /Remove-ProvisionedAppxPackage /PackageName:' & $aGET_PROVISIONEDAPPXPACKAGES[$i][4])
                                    EndIf
                                    _GUICtrlListView_DeleteItem($hGUI_LISTVIEW, $i)
                                Case 1
                                    If @OSArch = 'x64' Then
                                        DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 1) ;~ Turn On 64 Bit Redirection
                                        Run(@ComSpec & ' /k "' & @ScriptDir & '\Dism.exe /Online /Remove-ProvisionedAppxPackage /PackageName:' & $aGET_PROVISIONEDAPPXPACKAGES[$i][4])
                                        DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 0) ;~ Turn Off 64 Bit Redirection
                                    Else
                                        Run(@ComSpec & ' /k "' & @ScriptDir & '\Dism.exe /Online /Remove-ProvisionedAppxPackage /PackageName:' & $aGET_PROVISIONEDAPPXPACKAGES[$i][4])
                                    EndIf
                                    _GUICtrlListView_DeleteItem($hGUI_LISTVIEW, $i)
                            EndSwitch
                        EndIf
                    Next
                EndIf
        EndSwitch
    WEnd
    GUIDelete($hGUI_PROVISIONEDAPPXPACKAGES)
EndFunc   ;==>_GET_PROVISIONEDAPPXPACKAGES

Func _GET_DISMPATH()
    Local $bGET_DISM_FILEPATH = False, $sGET_DISM_FILEPATH, $hGUI_DISM_FILEPATH, $hGUI_DISMEXIT

    $sGET_DISM_FILEPATH = IniRead($sINI_EASYDISM, 'General', 'Dism File Path', @WindowsDir & '\System32\Dism.exe')
    If FileExists($sGET_DISM_FILEPATH) = 0 Then
        $sGET_DISM_FILEPATH = FileOpenDialog('Please Select Dism.exe File:', @ProgramFilesDir & '\', 'Dism (Dism.exe)', 3)
        If @error Then
            ;~ Begin    : Dism Install Dialogue GUI
            $hGUI_DISM_FILEPATH = GUICreate('Deployment Image Servicing and Management Tool', 470, 88)
            GUICtrlCreateLabel('Deployment Image Servicing and Management Tool (DISM) required please download and install Windows Assessment and Deployment Kit (ADK) using the link below:', 5, 5, 460, 28)
            GUICtrlCreateLabel(' - ', 5, 33, 15, 20, $SS_CENTERIMAGE)
            $hGUI_DISMLINK = GUICtrlCreateLabel('Windows Assessment and Deployment Kit (ADK)', 20, 33, 440, 20, $SS_CENTERIMAGE)
                GUICtrlSetBkColor($hGUI_DISMLINK, $GUI_BKCOLOR_TRANSPARENT)
                GUICtrlSetFont($hGUI_DISMLINK, 8.5, 400, 4, 'Arial')
                GUICtrlSetColor($hGUI_DISMLINK, 0x0000FF)
                GUICtrlSetCursor($hGUI_DISMLINK, 0)
            $hGUI_DISMEXIT = GUICtrlCreateButton('OK', 375, 58, 85, 25)
            GUISetState(@SW_SHOW, $hGUI_DISM_FILEPATH)
            While 1
                Switch GUIGetMsg()
                    Case $GUI_EVENT_CLOSE, $hGUI_DISMEXIT
                        ExitLoop
                    Case $hGUI_DISMLINK
                        ShellExecute(IniRead($sINI_EASYDISM, 'General', 'Dism Install', 'https://msdn.microsoft.com/en-us/windows/hardware/dn913721(v=vs.8.5).aspx'))
                        ExitLoop
                EndSwitch
            WEnd
            GUIDelete($hGUI_DISM_FILEPATH)
            Exit 0
            ;~ End  :  Dism Install Dialogue GUI
        Else
            $bGET_DISM_FILEPATH = True
        EndIf
    Else
        $bGET_DISM_FILEPATH = True
    EndIf

    If $bGET_DISM_FILEPATH Then
        Local $sENV_DISM_FILEPATH = _WinAPI_PathRemoveFileSpec($sGET_DISM_FILEPATH)
        Local $bENV_PATH_FILEPATH = False
        Local $sENV_PATH_FILEPATH = EnvGet('Path')
        Local $aENV_PATH_FILEPATH = StringSplit($sENV_PATH_FILEPATH, ';')
        For $i = 1 To $aENV_PATH_FILEPATH[0]
            If $aENV_PATH_FILEPATH[$i] = $sENV_DISM_FILEPATH Or $aENV_PATH_FILEPATH[$i] = '$sENV_DISM_FILEPATH$\' Then
                $bENV_PATH_FILEPATH = True
                ExitLoop
            EndIf
        Next
        If $bENV_PATH_FILEPATH = False Then
            EnvSet('PATH', '$sENV_PATH_FILEPATH$;$sGET_DISM_FILEPATH$')
            EnvUpdate()
        EndIf
        If $sGET_DISM_FILEPATH <> '@WindowsDir@\System32\Dism.exe' Then IniWrite($sINI_EASYDISM, 'General', 'DismPath', $sGET_DISM_FILEPATH)
        Return $sGET_DISM_FILEPATH
    EndIf
    Exit 0
EndFunc

 

Link to comment
Share on other sites

As for your getting the selected text/double click, you probably don't need to use the _IsPressed. Using sleep functions in a script is usually bad practice. Instead, just setting the input box from the selected text in your main loop should suffice

#include <GuiEdit.au3>
#include <GUIConstants.au3>

Global $hMain = GUICreate("", 400, 300)
Global $inpInput = GUICtrlCreateInput("", 10, 10, 380, 20)
Global $edtEdit = GUICtrlCreateEdit("", 10, 35, 380, 255)
Global $hEdit = GUICtrlGetHandle($edtEdit)

GUISetState(@SW_SHOW, $hMain)

While (True)
    Switch (GUIGetMsg())
        Case $GUI_EVENT_CLOSE
            Exit 0
        Case Else
            Local $aSel = _GUICtrlEdit_GetSel($hEdit)

            If (IsArray($aSel) And $aSel[0] <> $aSel[1]) Then GUICtrlSetData($inpInput, StringMid(GUICtrlRead($edtEdit), $aSel[0] + 1, $aSel[1]))
    EndSwitch
WEnd

 

Link to comment
Share on other sites

Its a sleep of 10ms... Bad practice or not, how do you make it, if you need it to be a double click? Sure you can not double click and copy the data continuously, but that's not what the OP asked.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

Inuno Taishou and careca sorry but Subz wins the day this time. Adding Remove App Package function to Easy_DISM was all his idea any how. I still have 2 tabs I would like to add the double click feature to will have to test both your ideas so Thank You both very much appreciated.

@Subz A few tweaks and works perfect! Changed Run to RunWait, when multiple pkgs selected DISM was trying to run the processes simultaneously. Changed ' k "' to ' c "' and finished off the cmd line with @SW_HIDE. Tested on offline and online Windows 8 and works flawlessly!

As for the DISM search function I had a different idea. I want to add a configuration tab and allow users to select the DISM location. Change @ScriptDir to a variable\handle and store the config options to an ini file. Your Dism search function goes way overboard. JFX made a great tool called GetWaik Tool it only downloads Dism necessary files less than 10mb. GetWaik Tool Download page.

Here is what I want to add to Easy_DISM and the config option will be next project.

#RequireAdmin
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <GuiTab.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>
#include <Constants.au3>
#include <Process.au3>
#include <ComboConstants.au3>
#include <WinAPIDlg.au3>
#include <GuiListView.au3>
#include <ColorConstants.au3>
#include <Array.au3>
#include <String.au3>
#include <FontConstants.au3.>
#include <GuiEdit.au3>
#include <ScrollBarsConstants.au3>
#include <GuiStatusBar.au3>
#include <File.au3>

$Form1 = GUICreate("Easy_DISM", 620, 680, -1, -1, -1, BitOR($WS_EX_WINDOWEDGE, $TCS_TOOLTIPS))

$c = ' /c '
$dismon = '\Dism.exe /Online"'
$miInfo = '\Dism.exe /Get-MountedImageInfo"'

$Tab1 = GUICtrlCreateTab(24, -1, 570, 600, BitOR($TCS_MULTILINE, $TCS_FLATBUTTONS))

;Start AppPkg Tab
$TabSheet12 = GUICtrlCreateTabItem("AppPkg")
$iStart_12 = GUICtrlCreateDummy() ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$T12Checkbox1 = GUICtrlCreateCheckbox("Online", 504, 80, 60, 17)
$T12Button1 = GUICtrlCreateButton("Browse", 504, 48, 75, 25)
$T12Button2 = GUICtrlCreateButton("Browse", 416, 298, 75, 25)
$T12Button3 = GUICtrlCreateButton("ADD", 504, 298, 75, 25)
$T12Button4 = GUICtrlCreateButton("Browse", 416, 325, 75, 25)
$T12Button5 = GUICtrlCreateButton("ADD", 504, 325, 75, 25)
$T12Button6 = GUICtrlCreateButton("Remove", 504, 352, 75, 25)
$T12Button8 = GUICtrlCreateButton("AppPkg Info", 504, 440, 75, 25)
$T12Edit1 = GUICtrlCreateEdit("", 120, 80, 370, 210, $ES_READONLY + $WS_VSCROLL + $WS_HSCROLL)
GUICtrlSetData(-1, "")
$T12Edit2 = GUICtrlCreateEdit("", 120, 380, 370, 210, $ES_READONLY + $WS_VSCROLL + $WS_HSCROLL)
GUICtrlSetData(-1, @CRLF & "Remove AppPkg: Select Online or Mount Folder" & @CRLF & "Click Remove Button and select the Apps you wish to remove" & @CRLF & @CRLF & "ADD App Package UNTESTED")
$T12Input1 = GUICtrlCreateInput("", 120, 48, 370, 21)
$T12Input2 = GUICtrlCreateInput("Used /SkipLicense option (error License required)", 120, 298, 281, 21)
$T12Input3 = GUICtrlCreateInput("Un Tested", 120, 325, 281, 21)
$T12Input4 = GUICtrlCreateInput("Click Remove and check Pkgs to be removed", 120, 352, 370, 21)
$T12Label1 = GUICtrlCreateLabel("Mount Folder", 45, 48, 62, 17)
$T12Label2 = GUICtrlCreateLabel("Single AppPkg", 45, 298, 70, 17)
$T12Label3 = GUICtrlCreateLabel("AppPkg Folder", 45, 325, 70, 17)
$T12Label4 = GUICtrlCreateLabel("Remove Apps", 45, 352, 70, 17)
$iEnd_12 = GUICtrlCreateDummy() ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
GUICtrlCreateTabItem("")
$Button1 = GUICtrlCreateButton("EXIT", 272, 650, 75, 25)
$progress = GUICtrlCreateEdit("", 120, 600, 380, 50, $ES_READONLY)
GUISetState(@SW_SHOW, $Form1)

$Run = Run(@ComSpec & $c & @ScriptDir & $miInfo, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
ProcessWaitClose($Run, 2)
$data = StdoutRead($Run)
GUICtrlSetData($T12Edit1, $data)
;GUICtrlSetData($T2Edit1, $data)
;GUICtrlSetData($T3Edit1, $data)
;GUICtrlSetData($T4Edit1, $data)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            Exit
        Case $iStart_12 To $iEnd_12
            _Tab_12($nMsg)

    EndSwitch
WEnd

Func _Tab_12($nMsg) ;<<<<< AppPkg Tab
    Switch $nMsg
        Case $T12Checkbox1
            If GUICtrlRead($T12Checkbox1) = $Gui_Checked Then
                GUICtrlSetState($T12Input1, $GUI_DISABLE)
                GUICtrlSetState($T12Button1, $GUI_DISABLE)
            ElseIf GUICtrlRead($T12Checkbox1) = $Gui_UnChecked Then
                GUICtrlSetState($T12Input1, $GUI_ENABLE)
                GUICtrlSetState($T12Button1, $GUI_ENABLE)
            EndIf
        Case $T12Button1
            $of_T3Button1 = FileSelectFolder("Select Mount Folder: ", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", 4)
            GUICtrlSetData($T12Input1, $of_T3Button1)
            $aRun = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Get-MountedImageInfo"', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
            ProcessWaitClose($aRun, 0)
            $adata = StdoutRead($aRun)
            GUICtrlSetData($T12Edit1, $adata)
        Case $T12Button2
            $of_T3Button2 = FileOpenDialog("Select Pkg File", @HomeDrive, "AppPkg Files (*.appx;*.appxbundle)", 1 + 4, "")
            GUICtrlSetData($T12Input2, $of_T3Button2)
        Case $T12Button3
            If GUICtrlRead($T12Checkbox1) = $Gui_UnChecked Then
                If GUICtrlRead($T12Input1) = "" Then
                    MsgBox(262144, "Empty.....", "No Mount Folder Selected!")
                    Return
                EndIf
                If GUICtrlRead($T12Input2) = "" Then
                    MsgBox(262144, "Empty.....", "No AppPkg Selected!")
                    Return
                EndIf
                $output = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Image:"' & GUICtrlRead($T12Input1) & '" /Add-ProvisionedAppxPackage /PackagePath:"' & GUICtrlRead($T12Input2) & '" /SkipLicense"', '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($output)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($T12Edit2, $progout)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            ElseIf GUICtrlRead($T12Checkbox1) = $Gui_Checked Then
                If GUICtrlRead($T12Input2) = "" Then
                    MsgBox(262144, "Empty.....", "No AppPkg Selected!")
                    Return
                EndIf
                $output = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Online /Add-ProvisionedAppxPackage /PackagePath:"' & GUICtrlRead($T12Input2) & '" /SkipLicense"', '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($output)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($T12Edit2, $progout)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            EndIf
        Case $T12Button4
            $of_T3Button4 = FileSelectFolder("Select Pkg : ", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", 4)
            GUICtrlSetData($T12Input3, $of_T3Button4)
        Case $T12Button5
            If GUICtrlRead($T12Checkbox1) = $Gui_UnChecked Then
                If GUICtrlRead($T12Input1) = "" Then
                    MsgBox(262144, "Empty.....", "No Mount Folder Selected!")
                    Return
                EndIf
                If GUICtrlRead($T12Input3) = "" Then
                    MsgBox(262144, "Empty.....", "No AppPkg Folder Selected!")
                    Return
                EndIf
                $output = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Image:"' & GUICtrlRead($T12Input1) & '" /Add-ProvisionedAppxPackage /FolderPath:"' & GUICtrlRead($T12Input3) & '""', '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($output)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($T12Edit2, $progout)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            ElseIf GUICtrlRead($T12Checkbox1) = $Gui_Checked Then
                If GUICtrlRead($T12Input3) = "" Then
                    MsgBox(262144, "Empty.....", "No AppPkg Folder Selected!")
                    Return
                EndIf
                $output = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Online /Add-ProvisionedAppxPackage /FolderPath:"' & GUICtrlRead($T12Input3) & '""', '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($output)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($T12Edit2, $progout)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            EndIf
        Case $T12Button6
            If GUICtrlRead($T12Checkbox1) = $Gui_UnChecked Then
                If GUICtrlRead($T12Input1) = "" Then
                    MsgBox(262144, "Empty.....", "No Mount Folder Selected!")
                    Return
                EndIf
                _GET_PROVISIONEDAPPXPACKAGES(@ComSpec & ' /c Dism.exe /Image:"' & GUICtrlRead($T12Input1) & '" /Get-ProvisionedAppxPackages', 0)
            ElseIf GUICtrlRead($T12Checkbox1) = $Gui_Checked Then
                _GET_PROVISIONEDAPPXPACKAGES(@ComSpec & ' /c Dism.exe /Online /Get-ProvisionedAppxPackages', 1)
            EndIf
        Case $T12Button8
            If GUICtrlRead($T12Checkbox1) = $Gui_UnChecked Then
                If GUICtrlRead($T12Input1) = "" Then
                    MsgBox(262144, "Empty.....", "No Mount Folder Selected!")
                    Return
                EndIf
                $bRun = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Image:"' & GUICtrlRead($T12Input1) & '" /Get-ProvisionedAppxPackages"', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($bRun)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($T12Edit2, $progout)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            ElseIf GUICtrlRead($T12Checkbox1) = $Gui_Checked Then
                $bRun = Run(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Online /Get-ProvisionedAppxPackages"', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                $progout = ""
                $progcatch = ""
                While 1
                    $progout &= StdoutRead($bRun)
                    If $progout <> $progcatch Then
                        GUICtrlSetData($T12Edit2, $progout)
                        $progcatch = $progout
                    EndIf
                    If @error Then ExitLoop
                WEnd
            EndIf
    EndSwitch
EndFunc   ;==>_Tab_12

Func _GET_PROVISIONEDAPPXPACKAGES($sDISM_PARAMETERS, $iDISM_ONLINEMODE = 0)
    Local $aGET_PROVISIONEDAPPXPACKAGES[0][5], $hRUN_PROVISIONEDAPPXPACKAGES
    If @OSArch = 'x64' Then
        DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 1) ;~ Turn On 64 Bit Redirection
        $hRUN_PROVISIONEDAPPXPACKAGES = Run($sDISM_PARAMETERS, '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
        DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 0) ;~ Turn Off 64 Bit Redirection
    Else
        $hRUN_PROVISIONEDAPPXPACKAGES = Run($sDISM_PARAMETERS, '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
    EndIf
    ProcessWaitClose($hRUN_PROVISIONEDAPPXPACKAGES)
    $sRUN_PROVISIONEDAPPXPACKAGES = StdoutRead($hRUN_PROVISIONEDAPPXPACKAGES)
    $aRUN_PROVISIONEDAPPXPACKAGES = StringSplit($sRUN_PROVISIONEDAPPXPACKAGES, @CR)
    For $x = 1 To $aRUN_PROVISIONEDAPPXPACKAGES[0]
        If StringInStr($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'DisplayName : ') Then
            ReDim $aGET_PROVISIONEDAPPXPACKAGES[UBound($aGET_PROVISIONEDAPPXPACKAGES) + 1][5]
            $aGET_PROVISIONEDAPPXPACKAGES[UBound($aGET_PROVISIONEDAPPXPACKAGES) - 1][0] = StringStripWS(StringReplace($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'DisplayName : ', ''), 7)
        EndIf
        If StringInStr($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'Version : ') Then
            $aGET_PROVISIONEDAPPXPACKAGES[UBound($aGET_PROVISIONEDAPPXPACKAGES) - 1][1] = StringStripWS(StringReplace($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'Version : ', ''), 7)
        EndIf
        If StringInStr($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'Architecture : ') Then
            $aGET_PROVISIONEDAPPXPACKAGES[UBound($aGET_PROVISIONEDAPPXPACKAGES) - 1][2] = StringStripWS(StringReplace($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'Architecture : ', ''), 7)
        EndIf
        If StringInStr($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'ResourceId : ') Then
            $aGET_PROVISIONEDAPPXPACKAGES[UBound($aGET_PROVISIONEDAPPXPACKAGES) - 1][3] = StringStripWS(StringReplace($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'ResourceId : ', ''), 7)
        EndIf
        If StringInStr($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'PackageName :') Then
            $aGET_PROVISIONEDAPPXPACKAGES[UBound($aGET_PROVISIONEDAPPXPACKAGES) - 1][4] = StringStripWS(StringReplace($aRUN_PROVISIONEDAPPXPACKAGES[$x], 'PackageName : ', ''), 7)
        EndIf
    Next
    Local $hGUI_PROVISIONEDAPPXPACKAGES = GUICreate('Get PackagexApps', 600, 600, -1, -1, -1, -1, $Form1)
    $hGUI_LISTVIEW = GUICtrlCreateListView('Display Name|Version|Architecture|ResourceId|Package Name', 5, 5, 590, 555, -1, BitOR($LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES))
    _GUICtrlListView_AddArray($hGUI_LISTVIEW, $aGET_PROVISIONEDAPPXPACKAGES)
    _GUICtrlListView_SetColumnWidth($hGUI_LISTVIEW, 0, 250)
    $hBTN_CLOSEGUI = GUICtrlCreateButton('Cancel', 290, 565, 150, 30)
    $hBTN_REMOVEAPP = GUICtrlCreateButton('Remove Packages', 445, 565, 150, 30)
    GUISetState(@SW_SHOW, $hGUI_PROVISIONEDAPPXPACKAGES)
    While 1
        $iPKG = GUIGetMsg()
        Switch $iPKG
            Case $GUI_EVENT_CLOSE, $hBTN_CLOSEGUI
                ExitLoop
            Case $hBTN_REMOVEAPP
                $iGUI_LISTVIEW = _GUICtrlListView_GetItemCount($hGUI_LISTVIEW)
                If $iGUI_LISTVIEW > 0 Then
                    For $i = $iGUI_LISTVIEW To 0 Step -1
                        If _GUICtrlListView_GetItemChecked($hGUI_LISTVIEW, $i) Then
                            Switch $iDISM_ONLINEMODE
                                Case 0
                                    If @OSArch = 'x64' Then
                                        DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 1) ;~ Turn On 64 Bit Redirection
                                        RunWait(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Image:"' & GUICtrlRead($T12Input1) & '" /Remove-ProvisionedAppxPackage /PackageName:"' & $aGET_PROVISIONEDAPPXPACKAGES[$i][4] & '""', '', @SW_HIDE)
                                        DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 0) ;~ Turn Off 64 Bit Redirection
                                    Else
                                        RunWait(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Image:"' & GUICtrlRead($T12Input1) & '" /Remove-ProvisionedAppxPackage /PackageName:"' & $aGET_PROVISIONEDAPPXPACKAGES[$i][4] & '""', '', @SW_HIDE)
                                    EndIf
                                    _GUICtrlListView_DeleteItem($hGUI_LISTVIEW, $i)
                                Case 1
                                    If @OSArch = 'x64' Then
                                        DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 1) ;~ Turn On 64 Bit Redirection
                                        RunWait(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Online /Remove-ProvisionedAppxPackage /PackageName:"' & $aGET_PROVISIONEDAPPXPACKAGES[$i][4] & '""', '', @SW_HIDE)
                                        DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 0) ;~ Turn Off 64 Bit Redirection
                                    Else
                                        RunWait(@ComSpec & ' /c "' & @ScriptDir & '\Dism.exe /Online /Remove-ProvisionedAppxPackage /PackageName:"' & $aGET_PROVISIONEDAPPXPACKAGES[$i][4] & '""', '', @SW_HIDE)
                                    EndIf
                                    _GUICtrlListView_DeleteItem($hGUI_LISTVIEW, $i)
                            EndSwitch
                        EndIf
                    Next
                EndIf
        EndSwitch
    WEnd
    GUIDelete($hGUI_PROVISIONEDAPPXPACKAGES)
EndFunc   ;==>_GET_PROVISIONEDAPPXPACKAGES

 

Edited by trashy
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...