Jump to content

Recommended Posts

  • 2 weeks later...

Hi, I tested it and you are correct. However, I do not have time to look at the problem now, but I tested v1.1a (this is a version I never released) and it did not crash on me. v1.2 mostly fixed 7zip installer issues. You can use v1.1a until I have time to work on this project again.

#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=gnome_app_install.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Array.au3>
#include <File.au3>
#include <FileConstants.au3>
#include <GDIPlus.au3>
#include <GUIConstants.au3>
#include <GuiTab.au3>
#include <GuiListView.au3>
#include <GuiMenu.au3>
#include <ProgressConstants.au3>
#include <String.au3>

Global $fIniConfig = @ScriptDir & "\Config.ini"
Global $sSWDir = @ScriptDir & "\Software\"
Global $sVersion = "1.1a"

; Main GUI
$Form1 = GUICreate("Software Installer", 633, 451)
$Tab1 = GUICtrlCreateTab(16, 8, 601, 377)
$TabSheet1 = GUICtrlCreateTabItem("Audio/Video/Photo")
$ListView1 = GUICtrlCreateListView("Software Name|Description", 24, 40, 582, 334)
_GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES))
GUICtrlSendMsg(-1, 0x101E, 0, 200)
GUICtrlSendMsg(-1, 0x101E, 1, 375)
$TabSheet2 = GUICtrlCreateTabItem("System Tools")
$ListView2 = GUICtrlCreateListView("Software Name|Description", 24, 40, 578, 334)
_GUICtrlListView_SetExtendedListViewStyle($ListView2, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES))
GUICtrlSendMsg(-1, 0x101E, 0, 200)
GUICtrlSendMsg(-1, 0x101E, 1, 375)
$TabSheet3 = GUICtrlCreateTabItem("Internet")
$ListView3 = GUICtrlCreateListView("Software Name|Description", 24, 40, 578, 334)
_GUICtrlListView_SetExtendedListViewStyle($ListView3, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES))
GUICtrlSendMsg(-1, 0x101E, 0, 200)
GUICtrlSendMsg(-1, 0x101E, 1, 375)
$TabSheet4 = GUICtrlCreateTabItem("Games")
$ListView4 = GUICtrlCreateListView("Software Name|Description", 24, 40, 578, 334)
_GUICtrlListView_SetExtendedListViewStyle($ListView4, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES))
GUICtrlSendMsg(-1, 0x101E, 0, 200)
GUICtrlSendMsg(-1, 0x101E, 1, 375)
$TabSheet5 = GUICtrlCreateTabItem("Miscellaneous")
$ListView5 = GUICtrlCreateListView("Software Name|Description", 24, 40, 578, 334)
_GUICtrlListView_SetExtendedListViewStyle($ListView5, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES))
GUICtrlSendMsg(-1, 0x101E, 0, 200)
GUICtrlSendMsg(-1, 0x101E, 1, 375)
$TabSheet6 = GUICtrlCreateTabItem("Patches/Updates")
$ListView6 = GUICtrlCreateListView("Software Name|Description", 24, 40, 578, 334)
_GUICtrlListView_SetExtendedListViewStyle($ListView6, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES))
GUICtrlSendMsg(-1, 0x101E, 0, 200)
GUICtrlSendMsg(-1, 0x101E, 1, 375)
$TabSheet7 = GUICtrlCreateTabItem("Productivity")
$ListView7 = GUICtrlCreateListView("Software Name|Description", 24, 40, 578, 334)
_GUICtrlListView_SetExtendedListViewStyle($ListView7, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES))
GUICtrlSendMsg(-1, 0x101E, 0, 200)
GUICtrlSendMsg(-1, 0x101E, 1, 375)
GUICtrlCreateTabItem("") ; This ends the tab item creation
$g1Checkbox1 = GUICtrlCreateCheckbox("Prompt to edit software installation order", 16, 400, 220, 17)
;~ GUICtrlSetState(-1, $GUI_CHECKED) ; Enable this if you want.
$g1Button1 = GUICtrlCreateButton("Install Selected Software", 398, 395, 219, 25, 0)
$MenuItem1 = GUICtrlCreateMenu("File")
$MenuItem1a = GUICtrlCreateMenuItem("Select All", $MenuItem1)
$MenuItem2 = GUICtrlCreateMenuItem("Unselect All", $MenuItem1)
$MenuItem3 = GUICtrlCreateMenuItem("Exit", $MenuItem1)
$MenuItem4 = GUICtrlCreateMenu("Settings")
$MenuItem5 = GUICtrlCreateMenuItem("Edit Software Configuration", $MenuItem4)
$MenuItem6 = GUICtrlCreateMenu("Help")
$MenuItem7 = GUICtrlCreateMenuItem("Help Topics", $MenuItem6)
$MenuItem8 = GUICtrlCreateMenuItem("About", $MenuItem6)
GUISetState(@SW_SHOW)

$aSoftwareList = _FileListToArrayRec(@ScriptDir & "\Software", "*.exe;*.msi;*.msu", 1, 1) ; List all software in Software folder.
If NOT IsArray ($aSoftwareList) Then ; Easy fix for program crashing if no software is in the Software folder.
    MsgBox(262144, "Error", "No software installers found in the Software folder." & @CRLF & "This program cannot function without any software installers." & @CRLF & "Add some to the folder and restart the program.")
    Exit
EndIf

For $i = 1 To 5 ; Add columns for other data.
    _ArrayColInsert($aSoftwareList, 1)
Next
Global $aUnconfiguredSW[$aSoftwareList[0][0]+1][5]
$aUnconfiguredSW[0][0] = 0
_CheckForNewSoftware($aSoftwareList)
If $aUnconfiguredSW[0][0] > 0 Then ; Get a list of all software that has not been configured.
    $iQueryUser = _QueryUser()
    If $iQueryUser = 1 Then
        _SWConfiguration()
    EndIf
EndIf
_Populate() ; Loads the software in the Software folder into the various lists.

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $g1Button1
            _InstallSelectedSoftware()
        Case $MenuItem1a
            _SelectAll(True)
        Case $MenuItem2
            _SelectAll(False)
        Case $MenuItem3
            Exit
        Case $MenuItem5
            _SWConfiguration()
        Case $MenuItem7
            _HelpTopics()
        Case $MenuItem8
            _About()
    EndSwitch
WEnd

Func _Populate()
    ; Find all files in the Software folder and populate the tabs with the installers.
    For $i = 1 To 7 ; Fill out the master array with data
        _GUICtrlListView_DeleteAllItems(Eval("ListView" & $i))
    Next
    For $i = 1 To $aSoftwareList[0][0]
        $sDisplayName = IniRead($fIniConfig, $aSoftwareList[$i][0], "DisplayName", $aSoftwareList[$i][0])
        If $sDisplayName = "" Then
            $sDisplayName = $aSoftwareList[$i][0]
        EndIf
        $sCategory = IniRead($fIniConfig, $aSoftwareList[$i][0], "Category", "")
        If $sCategory = "" Then
            $sCategory = 5
        EndIf
        $sDescription = IniRead($fIniConfig, $aSoftwareList[$i][0], "Description", "")
        $checked = IniRead($fIniConfig,$aSoftwareList[$i][0],"IsDefault", "")
        $aSoftwareList[$i][1] = $sDisplayName
        $aSoftwareList[$i][2] = $sCategory
        $aSoftwareList[$i][3] = $sDescription
        $aSoftwareList[$i][4] = $checked
    Next

    For $i = 1 To $aSoftwareList[0][0] ; Populate the tabs with items
        $iCategory = IniRead($fIniConfig, $aSoftwareList[$i][0], "Category", 5)
        $sDoNotShow = IniRead($fIniConfig, $aSoftwareList[$i][0], "DoNotShow", 0)
        If $sDoNotShow <> 1 Then
            GUICtrlCreateListViewItem($aSoftwareList[$i][1] & "|" & $aSoftwareList[$i][3], (Eval("ListView" & $iCategory)))
            If $aSoftwareList[$i][4] = 1 Then
                $iI = _GUICtrlListView_FindText((Eval("ListView" & $iCategory)), $aSoftwareList[$i][1])
                _GUICtrlListView_SetItemChecked((Eval("ListView" & $iCategory)), $iI, True)       ;Set checked radiobox of last found control
            EndIf
        EndIf
    Next
EndFunc   ;==>_Populate

Func _InstallSelectedSoftware()
    GUISetState(@SW_DISABLE, $Form1)
    Local $sExit = ""
    $Form4 = GUICreate("Installing Software", 443, 172)
    $g4Label1 = GUICtrlCreateLabel("Installing:", 16, 16, 148, 17)
    $g4Label2 = GUICtrlCreateLabel("", 16, 40, 418, 19)
    GUICtrlSetFont(-1, 10, 400, 0, "Arial Rounded MT Bold")
    GUICtrlSetColor(-1, 0x008080)
    $g4Label3 = GUICtrlCreateLabel("File Size:", 16, 64, 146, 17)
    $g4Label4 = GUICtrlCreateLabel("Total Progress:", 16, 112, 75, 17)
    $g4Progress1 = GUICtrlCreateProgress(16, 136, 414, 17)

    Local $aInstallList[$aSoftwareList[0][0] + 1][4]
    $iInstallListSize = 0
    For $i = 1 To 7
        $iItemCount = _GUICtrlListView_GetItemCount(Eval("ListView" & $i))
        For $j = 1 To $iItemCount
            $vItemChecked = _GUICtrlListView_GetItemChecked(Eval("ListView" & $i), $j - 1)
            If $vItemChecked = TRUE Then
                $iInstallListSize += 1
                $aInstallList[0][0] = $iInstallListSize
                $sItemName = _GUICtrlListView_GetItemText(Eval("ListView" & $i), $j - 1)
                $iArrayPos = _ArraySearch($aSoftwareList, $sItemName, Default, Default, Default, Default, Default, 1)
                $sSWInstaller = $aSoftwareList[$iArrayPos][0]
                $sSwitch = IniRead($fIniConfig, $sSWInstaller, "Switch", "")
                $aInstallList[$iInstallListSize][0] = $sSWDir & $sSWInstaller
                $aInstallList[$iInstallListSize][1] = $sSwitch
                $aInstallList[$iInstallListSize][2] = $sItemName
                $aInstallList[$iInstallListSize][3] = $sSWInstaller

            EndIf
        Next
    Next

    ReDim $aInstallList[$aInstallList[0][0] + 1][4]
    $iInstallOrder = GUICtrlRead($g1Checkbox1)
    If $iInstallOrder = 1 Then ; If the user wants to alter installation order, this pulls up the Gui.
        $aInstallList = _InstallOrder($aInstallList)
    EndIf

    GUISetState(@SW_SHOW, $Form4) ; The Installing Software screen has been hidden until now.

    For $i = 1 To $aInstallList[0][0] ; Set info into Gui and install the software.
        GUICtrlSetData($g4Label1, "Installing: " & $i & " of " & $aInstallList[0][0])
        GUICtrlSetData($g4Label2, $aInstallList[$i][2]) ; Name of software
        GUICtrlSetData($g4Label3, "File Size: " & Round(FileGetSize($aInstallList[$i][0])/1024000, 1) & " MB")
        $sInstallString = '"' & $aInstallList[$i][0] & '" ' & $aInstallList[$i][1]
        If StringRight($aInstallList[$i][0], 4) = ".msi" Then
            Run("msiexec /i " & $sInstallString)
        ElseIf StringRight($aInstallList[$i][0], 4) = ".msu" Then
            ShellExecuteWait($aInstallList[$i][0], $aInstallList[$i][1])
        Else
            If StringInStr($aInstallList[$i][0], "7z") Then
                RegDelete("HKEY_CURRENT_USER\Software\7-Zip", "Path")
                RegDelete("HKEY_CURRENT_USER\Software\7-Zip", "Path32")
                RegDelete("HKEY_CURRENT_USER\Software\7-Zip", "Path64")
                $sInstallSwitch = '/S /D="' & @HomeDrive & '\Program Files\7-Zip"'
                RunWait('"' & $aInstallList[$i][0] & '" ' & $sInstallSwitch)
            Else
                RunWait('"' & $aInstallList[$i][0] & '" ' & $aInstallList[$i][1])
            EndIf
;~          FileMove(@ScriptDir & "\SoftwareInstaller.log", @ScriptDir & "\SoftwareInstaller.log", 8)
;~          FileWrite(@ScriptDir & "\SoftwareInstaller.log", "Script:    " & '"' & $aInstallList[$i][0] & '" ' & $aInstallList[$i][1] & @CRLF)
;~          If NOT FileExists($aInstallList[$i][0]) Then
;~              FileWrite(@ScriptDir & "\SoftwareInstaller.log", "File does not exist:       " & $aInstallList[$i][0] & @CRLF )
;~          EndIf
;~          If FileExists (@HomeDrive & "\Program Files\7-Zip\7z.exe") Then
;~              FileWrite(@ScriptDir & "\SoftwareInstaller.log", "7z.exe found in program files" & @CRLF )
;~          EndIf
        EndIf
        $sPostInstall = IniRead($fIniConfig, $aInstallList[$i][3], "PostInstall", "")
        If $sPostInstall <> "" Then
            If StringRight($sPostInstall, 4) = ".reg" Then
                Run("REGEDIT /S " & '"' & $sPostInstall & '"')
            Else
                ShellExecute($sPostInstall)
            EndIf
        EndIf
        GUICtrlSetData($g4Progress1, $i/$aInstallList[0][0]*100)
    Next
;~  $sExit = "EXIT"
;~  Do
;~      Sleep(500)
;~  Until $sExit = "EXIT"

    GUISetState(@SW_ENABLE, $Form1)
    GUIDelete($Form4)
    _SelectAll(False)
EndFunc

Func _SelectAll($TF) ; Sending TRUE or FALSE to select all or unselect all.
    For $i = 1 To 7
        $iItemCount = _GUICtrlListView_GetItemCount(Eval("ListView" & $i))
        For $j = 1 To $iItemCount
            _GUICtrlListView_SetItemChecked(Eval("ListView" & $i), $j - 1, $TF)
        Next
    Next
EndFunc   ;==>_SelectAll

Func _HelpTopics()
    $Form2 = GUICreate("Help", 633, 447)
    $Label1 = GUICtrlCreateLabel("", 8, 16, 612, 425)
    GUICtrlSetData(-1, "This program uses silent switches to install software without user interaction. " & _
    "To use this functionality, you can edit the Config.ini file to add software and their switches. Example: " & _
    @CRLF & @CRLF & "[7z1900-x64.exe] ; <--- This is the actual file name" & _
    @CRLF & "Description=YourDescripton" & @CRLF & "Switch=YourSwitcth" & @CRLF & "Category=YourCategory" & @CRLF & "etc... etc..." & _
    @CRLF & @CRLF & "Here are some common switches for various installers: (more included in this program's features)" & @CRLF & @CRLF & "/silent used for Inno Setup installers" & @CRLF & _
    "/verysilent used for Inno Setup installers" & @CRLF & "/S used for Nullsoft (aka NSIS) installers" & @CRLF & "/s used for Wise installers" & _
    @CRLF & "-s used for Ghost installers" & @CRLF & "-ms used for Mozilla installers" & @CRLF & "/quiet used for Microsoft installers" & @CRLF & _
    "/qb used for Microsoft installers" & @CRLF & "/qn used for  Microsoft installers" & @CRLF & "/passive used for Microsoft installers" & @CRLF & _
    "/Q used for Microsoft installers")
    GUISetState(@SW_SHOW)

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                GUIDelete($Form2)
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>_HelpTopics

Func _CheckForNewSoftware($aSoftwareList)
    Local $aConfigFileSW = IniReadSectionNames($fIniConfig)
        $iArrayPos = 1
        For $i = 1 To $aSoftwareList[0][0]
            If _ArraySearch($aConfigFileSW, $aSoftwareList[$i][0]) < 1 Then
                $aUnconfiguredSW[$iArrayPos][0] = $aSoftwareList[$i][0]
                $aUnconfiguredSW[0][0] = $iArrayPos
                $iArrayPos += 1
            EndIf
        Next
EndFunc

Func _SWConfiguration()
    GUISetState(@SW_DISABLE, $Form1)
;~  $strPassToGui = "$g2Input1, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input2, $g2Button1, $g2Button2, $g2Checkbox1, $g2Checkbox2, $g2Label7, $g2List, $g2Label8, $g2Input3, $g2Button3, "
    $Form2 = GUICreate("Configure Software", 620, 490)
    Global $g2List = GUICtrlCreateList("", 8, 24, 602, 218)
    $g2Checkbox1 = GUICtrlCreateCheckbox("Show All Software", 8, 240, 121, 17)
    $g2Label1 = GUICtrlCreateLabel("Display Name For Software:", 8, 264, 250, 17)
    $g2Input1 = GUICtrlCreateInput("", 8, 280, 250, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $g2Label2 = GUICtrlCreateLabel("Installer Type (optional):", 8, 320, 116, 17)
    $g2Combo1 = GUICtrlCreateCombo("", 8, 336, 170, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
    GUICtrlSetState(-1, $GUI_DISABLE)
    $g2Button4 = GUICtrlCreateButton("Detect", 185, 335, 75, 23)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $g2Label3 = GUICtrlCreateLabel("Silent Switch To Be Used:", 8, 376, 128, 17)
    $g2Combo2 = GUICtrlCreateCombo("", 8, 392, 250, 25)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $g2Label4 = GUICtrlCreateLabel("Software Description (optional):", 300, 264, 250, 17)
    $g2Input2 = GUICtrlCreateInput("", 300, 280, 250, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $g2Label5 = GUICtrlCreateLabel("Category:", 300, 320, 128, 17)
    $g2Combo3 = GUICtrlCreateCombo("", 300, 336, 250, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
    GUICtrlSetState(-1, $GUI_DISABLE)
    $g2Label6 = GUICtrlCreateLabel("Double-Click Each Software To Configure. When Finished, Click The Save Button", 8, 6, 391, 17)
    $g2Label7 = GUICtrlCreateLabel("Editing: ", 8, 240, 602, 17)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    GUICtrlSetColor(-1, 0x008000)
    GUICtrlSetBkColor(-1, 0xC0DCC0)
    GUICtrlSetState(-1, $GUI_HIDE)
    $g2Checkbox2 = GUICtrlCreateCheckbox("This Software Defaults To Selected (Check Mark On)", 8, 430, 280, 17)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $g2Checkbox3 = GUICtrlCreateCheckbox("Hide This Item On Main GUI", 8, 450, 280, 17)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $g2Label8 = GUICtrlCreateLabel("Run After Install (optional - registry file, executable, etc)", 300, 376, 307, 17)
    $g2Input3 = GUICtrlCreateInput("", 300, 392, 200, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $g2Button3 = GUICtrlCreateButton("Select", 505, 391, 75, 23, $WS_GROUP)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $g2Button1 = GUICtrlCreateButton("Edit A Different Software", 300, 440, 160, 27, $WS_GROUP)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $g2Button2 = GUICtrlCreateButton("Save Data", 480, 440, 100, 27, $WS_GROUP)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUISetState(@SW_SHOW)
    _ClearAndSetInputs($g2List, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input1, $g2Input2, $g2Input3, $g2Label7, $g2Checkbox1, $g2Checkbox2, $g2Checkbox3, $aUnconfiguredSW)
    Global $idDummy = GUICtrlCreateDummy()
    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE ; Exit - does not save unsaved data. No prompts given to reduce annoying popups.
                GUISetState(@SW_ENABLE, $Form1)
                GUIDelete($Form2)
                _Populate()
                ExitLoop
            Case $idDummy ; Something on the list has been double-clicked. Change to edit mode for the selected software.
                _ClearAndSetInputs($g2List, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input1, $g2Input2, $g2Input3, $g2Label7, $g2Checkbox1, $g2Checkbox2, $g2Checkbox3, $aUnconfiguredSW)
                GUICtrlSetData($g2Label7, "Editing: " & GUICtrlRead($idDummy))
                $sDesc = IniRead($fIniConfig, GUICtrlRead($idDummy), "Description", "")
                $sFullSwitches = "-s|/silent|/verysilent|/sp- /silent /norestart|/verysilent /norestart|/S|/S /NCRC|/passive|/passive /norestart|/u|/u /z|/q|/q /r:n|/q:a|/qb|/qn|/q:a /r:n|/S|/s"
                $sSwitch = IniRead($fIniConfig, GUICtrlRead($idDummy), "Switch", $sFullSwitches)
                Local $aCategories[8] = ["7","Audio/Video/Photo", "System Tools", "Internet", "Games", "Miscellaneous", "Patches/Updates", "Productivity"]
                $iCategory = IniRead($fIniConfig, GUICtrlRead($idDummy), "Category", "5")
                $sCategory = $aCategories[$iCategory]
                $sDisplayName = IniRead($fIniConfig, GUICtrlRead($idDummy), "DisplayName", "")
                $sIsDefault = IniRead($fIniConfig, GUICtrlRead($idDummy), "IsDefault", "")
                If $sIsDefault = 1 Then
                    GUICtrlSetState($g2Checkbox2, $GUI_CHECKED)
                EndIf
                $sDoNotShow = IniRead($fIniConfig, GUICtrlRead($idDummy), "DoNotShow", 0)
                If $sDoNotShow = 1 Then
                    GUICtrlSetState($g2Checkbox3, $GUI_CHECKED)
                EndIf
                GUICtrlSetData($g2Input1, $sDisplayName)
                GUICtrlSetData($g2Combo2, $sSwitch, $sSwitch)
                GUICtrlSetData($g2Input2, $sDesc)
                GUICtrlSetData($g2Combo3, $sCategory)
                GUICtrlSetData($g2List, "")
                GUICtrlSetData($g2List, GUICtrlRead($idDummy))
                $sRunPostInstall = IniRead($fIniConfig, GUICtrlRead($idDummy), "PostInstall", "")
                GUICtrlSetData($g2Input3, $sRunPostInstall)
                _EnableDisableControls($g2Input1, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input2, $g2Button1, $g2Button2, $g2Button3, $g2Button4, $g2Checkbox1, $g2Checkbox2, $g2Checkbox3, $g2Label7, $g2List, $g2Label8, $g2Input3, 1) ; enable
            Case $g2Button1 ; Discard any unsaved data that has been entered and switch back to software selection mode.
                GUICtrlSetData($g2Button4, "Detect")
                _ClearAndSetInputs($g2List, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input1, $g2Input2, $g2Input2, $g2Label7, $g2Checkbox1, $g2Checkbox2, $g2Checkbox3, $aUnconfiguredSW)
                _EnableDisableControls($g2Input1, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input2, $g2Button1, $g2Button2, $g2Button3, $g2Button4, $g2Checkbox1, $g2Checkbox2, $g2Checkbox3, $g2Label7, $g2List, $g2Label8, $g2Input3, 0)
            Case $g2Combo1
                _SetSwitchData($g2Combo1, $g2Combo2, $g2Combo3)
            Case $g2Checkbox1 ; Toggles between unconfigured software to all software (configured & unconfigured).
                $iCBRead = GUICtrlRead($g2Checkbox1)
                If $iCBRead = 1 Then
                    _ClearAndSetInputs($g2List, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input1, $g2Input2, $g2Input3, $g2Label7, $g2Checkbox1, $g2Checkbox2, $g2Checkbox3, $aSoftwareList)
                Else
                    _ClearAndSetInputs($g2List, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input1, $g2Input2, $g2Input3, $g2Label7, $g2Checkbox1, $g2Checkbox2, $g2Checkbox3, $aUnconfiguredSW)
                EndIf
            Case $g2Button2 ; Save data and switch back to software selection mode.
                GUICtrlSetData($g2Button4, "Detect")
                $sCurrentSW = StringTrimLeft(GUICtrlRead($g2Label7), 9) ; Trim off the left wing "Editing: " to get the current software name.
                $sDesc = IniWrite($fIniConfig, $sCurrentSW, "Description", GUICtrlRead($g2Input2))
                $sSwitch = IniWrite($fIniConfig, $sCurrentSW, "Switch", GUICtrlRead($g2Combo2)) ; Having a problem with this line when saving switch data when in "all software" mode, or at least i think this is a problem.
                Local $aCategories[8] = ["7","Audio/Video/Photo", "System Tools", "Internet", "Games", "Miscellaneous", "Patches/Updates", "Productivity"]
                $sCategory = GUICtrlRead($g2Combo3)
                $iArrayPos = _ArraySearch($aCategories, $sCategory)
                IniWrite($fIniConfig, $sCurrentSW, "Category", $iArrayPos)
                $sDisplayName = IniWrite($fIniConfig, $sCurrentSW, "DisplayName", GUICtrlRead($g2Input1))
                $sRunPostInstall = IniWrite($fIniConfig, $sCurrentSW, "PostInstall", GUICtrlRead($g2Input3))
                $sIsDefault = IniWrite($fIniConfig, $sCurrentSW, "IsDefault", GUICtrlRead($g2Checkbox2))
                $iArrayPos = _ArraySearch($aUnconfiguredSW, $sCurrentSW)
                If $iArrayPos > 0 Then
                    _ArrayDelete($aUnconfiguredSW, $iArrayPos)
                    $aUnconfiguredSW[0][0] -= 1
                EndIf
                $sDoNotShow = GUICtrlRead($g2Checkbox3)
                IniWrite($fIniConfig, $sCurrentSW, "DoNotShow", $sDoNotShow)
                _ClearAndSetInputs($g2List, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input1, $g2Input2, $g2Input3, $g2Label7, $g2Checkbox1, $g2Checkbox2, $g2Checkbox3, $aUnconfiguredSW)
                _EnableDisableControls($g2Input1, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input2, $g2Button1, $g2Button2, $g2Button3, $g2Button4, $g2Checkbox1, $g2Checkbox2, $g2Checkbox3, $g2Label7, $g2List, $g2Label8, $g2Input3, 0)
            Case $g2Button3 ; Select a file to run after the software is installed.
                $sRunPostInstall = FileOpenDialog("Select A File", @ScriptDir & "\Software", "Registry (*.reg;*.key)|Executables (*.exe)")
                GUICtrlSetData($g2input3, $sRunPostInstall)
            Case $g2Button4 ; Detect the installer type
                _GetInstallerType($idDummy, $g2Combo1, $g2Combo2, $g2Combo3, $g2Button4)
        EndSwitch
    WEnd
EndFunc

Func _GetInstallerType($idDummy, $g2Combo1, $g2Combo2, $g2Combo3, $g2Button4)
    If StringRight(GUICtrlRead($idDummy), 4) = ".msi" Then
        GUICtrlSetData($g2Combo1, "MSI Package")
        _SetSwitchData($g2Combo1, $g2Combo2, $g2Combo3)
    ElseIf StringRight(GUICtrlRead($idDummy), 4) = ".msu" Then
        GUICtrlSetData($g2Combo1, "Microsoft Hotfix Package")
        _SetSwitchData($g2Combo1, $g2Combo2, $g2Combo3)
    Else
        $sFileName = @ScriptDir & "\Software\" & GUICtrlRead($idDummy)
        $hFileOpen = FileOpen($sFileName)
        Local $sFileRead = FileRead($hFileOpen, 8000000) ; Only read the first 1 MB of the file for speed and prevent crashing. If installer type is in plain text, it will probably be in this section of the file.
        $sSearchStrings = "(496E6E6F205365747570|4E756C6C736F6674)" ;Inno Setup|Nullsoft
        $aMatch = StringRegExp($sFileRead, $sSearchStrings, 1)
        $sFileRead = ""
        FileClose($hFileOpen)

        #cs
        New ideas... Just found out that FileGetVersion can tell you the productname and now I can get the name of certain software without reading the hex code of the
        executable. Now, I should FIRST read for Inno Setup, Nullsoft and Mozilla (because all their products use -ms switch).
        Then after searching for those keywords, I can search for others like WinRar, uTorrent, Acrobat, Chrome, etc.
        I need to pay attention to the order in which they are processed. I need broad ones first (Inno, NSIS) then smaller ones that fell through the cracks.
        I need to find out the most popular software out there in each category.

        or maybe search for non standard software, if none found, read the first mb of the file for keywords, if nothing is found, then set "unknown" software message.
        this actually might be better because reading attributes will be light before reading a megabyte of a file. This will only be comparing a few bytes a dozen times or so.

        #ce

        $sTestMode = 0
        $sSwitchFound = 0
        If IsArray($aMatch) Then ; If a match is found, decode the hex to ascii and set that to the combo.
            $sDecoded = _HexToString($aMatch[0])
            GUICtrlSetData($g2Combo1, $sDecoded)
            _SetSwitchData($g2Combo1, $g2Combo2, $g2Combo3)
            $sSwitchFound = 1
        EndIf
        If  $sSwitchFound = 0 Then
            $sProdName = FileGetVersion($sFileName, $FV_PRODUCTNAME)
            If $sTestMode = 1 Then
                FileRecycle($sFileName)
                FileWrite("Installers.db", $sProdName & "|" & @CRLF)
            EndIf
            If $sProdName <> "" Then
                $sSilentSwitches = IniRead(@ScriptDir & "\Installers.db", $sProdName, "Switches", "")
                $sSilentSwitch = IniRead(@ScriptDir & "\Installers.db", $sProdName, "DefaultSwitch", "")
                $sProdName = "[ " & $sProdName & " ]"
                GUICtrlSetData($g2Combo1, "") ; Clear drop-down data to replenish it.
                GUICtrlSetData($g2Combo1, $sProdName, $sProdName)
                GUICtrlSetData($g2Combo2, "") ; Clear drop-down data to replenish it.
;~              MsgBox(0, "", $sSilentSwitch)
                GUICtrlSetData($g2Combo2, $sSilentSwitches, $sSilentSwitch)
            EndIf
        Else
            GUICtrlSetData($g2Button4, "Unknown") ; If no match if found, set the button to "unknown" and disable it. It will get re-enabled on the next software selected.
            GUICtrlSetState($g2Button4, $GUI_DISABLE)
        EndIf

    EndIf
EndFunc

Func _SetSwitchData($g2Combo1, $g2Combo2, $g2Combo3)
    $sInstaller = GUICtrlRead($g2Combo1)
    GUICtrlSetData($g2Combo2, "")
    If $sInstaller = "Ghost Installer" Then
        GUICtrlSetData($g2Combo2, "-s", "-s")
    ElseIf $sInstaller = "Inno Setup" Then
        GUICtrlSetData($g2Combo2, "/silent|/verysilent|/sp- /silent /norestart|/verysilent /norestart", "/verysilent /norestart")
    ElseIf $sInstaller = "InstallShield" Then
        GUICtrlSetData($g2Combo2, "/S|/S /NCRC", "/S")
    ElseIf $sInstaller = "Microsoft Hotfix Package" Then
        GUICtrlSetData($g2Combo2, "/passive|/passive /norestart|/quiet|/quiet /norestart|/u|/u /z|/q|/q /r:n|/q:a|/qb|/qn|/q:a /r:n", "/quiet /norestart")
        GUICtrlSetData($g2Combo3, "Patches/Updates")
    ElseIf $sInstaller = "MSI Package" Then
        GUICtrlSetData($g2Combo2, "/qb|/qn", "/qn")
    ElseIf $sInstaller = "Nullsoft" Then
        GUICtrlSetData($g2Combo2, "/S", "/S")
    ElseIf $sInstaller = "Wise Installer" Then
        GUICtrlSetData($g2Combo2, "/s", "/s")
    Else
        GUICtrlSetData($g2Combo2, "-s|/silent|/verysilent|/sp- /silent /norestart|/verysilent /norestart|/S|/S /NCRC|/passive|/passive /norestart|/u|/u /z|/q|/q /r:n|/q:a|/qb|/qn|/q:a /r:n|/S|/s")
    EndIf
EndFunc

;~ Func _EnableDisableControls($g2Input1, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input2, $g2Button1, $g2Button2, $g2Checkbox1, $g2Checkbox2, $g2Label7, $g2List, $g2Label8, $g2Input3, $g2Button3, $01)
Func _EnableDisableControls($g2Input1, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input2, $g2Button1, $g2Button2, $g2Button3, $g2Button4, $g2Checkbox1, $g2Checkbox2, $g2Checkbox3, $g2Label7, $g2List, $g2Label8, $g2Input3, $01)
    GUICtrlSetState($g2Input1, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE)
    GUICtrlSetState($g2Combo1, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE)
    GUICtrlSetState($g2Combo2, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE)
    GUICtrlSetState($g2Combo3, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE)
    GUICtrlSetState($g2Input2, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE)
    GUICtrlSetState($g2Checkbox1, ($01 = 1) ? $GUI_HIDE : $GUI_SHOW)
    GUICtrlSetState($g2Checkbox2, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE)
    GUICtrlSetState($g2Checkbox3, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE)
    GUICtrlSetState($g2Button1, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE)
    GUICtrlSetState($g2Button2, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE)
    GUICtrlSetState($g2Button4, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE)
    GUICtrlSetState($g2Label7, ($01 = 1) ? $GUI_SHOW : $GUI_HIDE)
    GUICtrlSetState($g2List, ($01 = 1) ? $GUI_DISABLE : $GUI_ENABLE)
    GUICtrlSetState($g2Input3, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE)
    GUICtrlSetState($g2Button3, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE)
EndFunc

Func _ClearAndSetInputs($g2List, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input1, $g2Input2, $g2Input3, $g2Label7, $g2Checkbox1, $g2Checkbox2, $g2Checkbox3, $aSW, $iSWList = 0)
    GUICtrlSetData($g2List, "")
    GUICtrlSetData($g2Input1, "")
    GUICtrlSetData($g2Input2, "")
    GUICtrlSetData($g2Input3, "")
    GUICtrlSetData($g2Combo1, "")
    GUICtrlSetData($g2Combo2, "")
    GUICtrlSetData($g2Combo3, "")
    GUICtrlSetData($g2Combo1, "Ghost Installer|Inno Setup|InstallShield|Microsoft Hotfix Package|MSI Package|Nullsoft|Wise Installer")
    _SetSwitchData($g2Combo1, $g2Combo2, $g2Combo3)
    GUICtrlSetData($g2Combo3, "Audio/Video/Photo|System Tools|Internet|Games|Miscellaneous|Patches/Updates|Productivity", "Miscellaneous")
    GUICtrlSetState ($g2Checkbox2, $GUI_UNCHECKED)
    $iCBRead = GUICtrlRead($g2Checkbox1)

    If $iCBRead = 1 Then
        If IsArray($aSoftwareList) Then
            For $i = 1 To $aSoftwareList[0][0]
                GUICtrlSetData($g2List, $aSoftwareList[$i][0])
            Next
        EndIf
    Else
        If IsArray($aUnconfiguredSW) Then
            For $i = 1 To $aUnconfiguredSW[0][0]
                GUICtrlSetData($g2List, $aUnconfiguredSW[$i][0])
            Next
        EndIf
    EndIf
EndFunc

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    Local $hWndFrom, $iIDFrom, $iCode, $hWndEdit
    $hWndFrom = $lParam
    $iIDFrom = _WinAPI_LoWord($wParam)
    $iCode = _WinAPI_HiWord($wParam)
    If $iCode = $LBN_DBLCLK AND $iIDFrom = $g2List Then
        $sClicked = GUICtrlRead($g2List)
        GUICtrlSendToDummy($idDummy, $sClicked)
    EndIf
EndFunc

Func _InstallOrder($aInstallList)
    GUISetState(@SW_DISABLE, $Form1)
    $Form5 = GUICreate("Installation Order", 423, 292)
    $g5Label1 = GUICtrlCreateLabel("Highlight software and click the up and down arrows to change order of installation", 16, 3, 393, 17)
    $g5List1 = GUICtrlCreateList("", 16, 24, 321, 253, $LBS_NOTIFY)
    $g5Button1 = GUICtrlCreateButton(ChrW(8593), 344, 112, 35, 25, $WS_GROUP)
    $g5Button2 = GUICtrlCreateButton(ChrW(8595), 344, 144, 35, 25, $WS_GROUP)
    $g5Button3 = GUICtrlCreateButton("Done", 351, 251, 59, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    For $i = 1 To $aInstallList[0][0]
        GUICtrlSetData($g5List1, $aInstallList[$i][3])
    Next

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                GUISetState(@SW_ENABLE, $Form1)
                GUIDelete($Form5)
                Return $aInstallList
                ExitLoop
            Case $g5Button1
                $sRead = GUICtrlRead($g5List1)
                If $sRead <> "" Then
                    $iArrayPos = _ArraySearch($aInstallList, $sRead, Default, Default, Default,Default,Default, 3)
                    If $iArrayPos > 1 Then
                        _ArraySwap($aInstallList, $iArrayPos, $iArrayPos - 1)
                    EndIf
                    GUICtrlSetData($g5List1, "")
                    For $i = 1 To $aInstallList[0][0]
                        GUICtrlSetData($g5List1, $aInstallList[$i][3])
                    Next
                EndIf
            Case $g5Button2
                $sRead = GUICtrlRead($g5List1)
                If $sRead <> "" Then
                    $iArrayPos = _ArraySearch($aInstallList, $sRead, Default, Default, Default,Default,Default, 3)
                    If $iArrayPos < $aInstallList[0][0] Then
                        _ArraySwap($aInstallList, $iArrayPos, $iArrayPos + 1)
                    EndIf
                    GUICtrlSetData($g5List1, "")
                    For $i = 1 To $aInstallList[0][0]
                        GUICtrlSetData($g5List1, $aInstallList[$i][3])
                    Next
                EndIf
            Case $g5Button3
                GUISetState(@SW_ENABLE, $Form1)
                GUIDelete($Form5)
                Return $aInstallList
                ExitLoop
        EndSwitch
    WEnd
EndFunc

Func _QueryUser()
    $iShowConfigSWDiag = IniRead($fIniConfig, "Settings", "ShowConfigSWDiag", 4)
    If $iShowConfigSWDiag = 4 Then
        GUISetState(@SW_DISABLE, $Form1)
        $iStyle2 = BitOr( $WS_CAPTION, $WS_POPUP, $WS_SYSMENU)
        $Form6 = GUICreate("Attention", 423, 119, Default, Default, $iStyle2)
        $g6Label1 = GUICtrlCreateLabel("You have unconfigured software. Do you want to configure them now?", 32, 32, 338, 17)
        $g6Button1 = GUICtrlCreateButton("Yes", 184, 72, 99, 25, $WS_GROUP)
        $g6Button2 = GUICtrlCreateButton("No", 296, 72, 99, 25, $WS_GROUP)
        $g6Checkbox1 = GUICtrlCreateCheckbox("Do not ask again", 32, 80, 121, 17)
        GUISetState()
        $g6ExitButton = _GUICtrlMenu_GetSystemMenu($Form6)
        _GUICtrlMenu_EnableMenuItem($g6ExitButton, $SC_CLOSE, 1, False)

        While 1
            $nMsg = GUIGetMsg()
            Switch $nMsg
                Case $g6Button1
                    $iCBRead = GUICtrlRead($g6Checkbox1)
                    If $iCBRead = 1 Then
                        IniWrite($fIniConfig, "Settings", "ShowConfigSWDiag", $iCBRead)
                    EndIf
                    GUISetState(@SW_ENABLE, $Form1)
                    GUIDelete($Form6)
                    Return 1
                    ExitLoop
                Case $g6Button2
                    $iCBRead = GUICtrlRead($g6Checkbox1)
                    If $iCBRead = 1 Then
                        IniWrite($fIniConfig, "Settings", "ShowConfigSWDiag", $iCBRead)
                    EndIf
                    GUISetState(@SW_ENABLE, $Form1)
                    GUIDelete($Form6)
                    Return 0
                    ExitLoop
            EndSwitch
        WEnd
    EndIf
EndFunc

Func _About()
    GUISetState(@SW_DISABLE, $Form1)
    Local $Form3, $hGraphic
    Local Const $iWidth = 400, $iHeight = 150, $iBgColor = 0x303030
    $Form3 = GUICreate("About Software Installer", 400, 300)
    GUISetBkColor($iBgColor, $Form3)
    GUISetState(@SW_SHOW)
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($Form3)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFEE88BB)
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($Form3)
    _GDIPlus_GraphicsFillRect($hGraphic, 0, 150, 400, 300, $hBrush)

    $Label1 = GUICtrlCreateLabel("Software Installer", 48, 16, 304, 44)
    GUICtrlSetFont(-1, 26, 400, 0, "Arial Rounded MT Bold")
    GUICtrlSetColor(-1, 0xC0C0C0)
    $Label2 = GUICtrlCreateLabel("Version " & $sVersion, 48, 56, 100, 22)
    GUICtrlSetFont(-1, 12, 400, 0, "Arial")
    GUICtrlSetColor(-1, 0xC0C0C0)
    $Label3 = GUICtrlCreateLabel("Click here to go to the home page for this software", 48, 240, 300, 21)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    GUICtrlSetColor(-1, 0x000080)
    GUICtrlSetBkColor(-1, 0x434E54)
    GUICtrlSetCursor (-1, 0)
    $Label4 = GUICtrlCreateLabel("Scripted with AutoIt", 48, 200, 115, 20)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    GUICtrlSetColor(-1, 0x808080)
    $Label5 = GUICtrlCreateLabel("This software is designed to help automate unattended and/or silent software installation.", 56, 96, 282, 40)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    GUICtrlSetColor(-1, 0x00FFFF)

    While 1
        $nmsg = GUIGetMsg()
        Switch $nMsg
            Case $Label3
                ShellExecute ("https://www.autoitscript.com/forum/topic/143730-software-installer/")
            Case $GUI_EVENT_CLOSE
                _GDIPlus_BrushDispose($hBrush)
                _GDIPlus_GraphicsDispose($hGraphic)
                _GDIPlus_Shutdown()
                GUISetState(@SW_ENABLE, $Form1)
                GUIDelete($Form3)
                ExitLoop
        EndSwitch
    WEnd
EndFunc

 

Link to comment
Share on other sites

A quick question for @abberration

I have the Volatran software installer (link is in my signature) and one of my features is it can look at what OS one has so it won't install something that the OS doesn't support. Also it does profiles so when say you have a department that always has the same software, you can simply pick that profile and all the needed software is automatically added to the list of items to install. 

How hard would it be to add those features?

Link to comment
Share on other sites

Hi, Bert.

Those are some great suggestions. Thank you so much for them. I am working them out in my head as I speak.

I really like the one concerning profiles. Currently, it allows the user to specify which software are checked by default (just the one profile). This could easily be modified for different profiles (ABC Company, APEX Corp, etc, using the company name as the section name in the ini file).  Great addition, I will definitely implement it, hopefully on the next version. On the next version, I will add a tab on the listview that shows the silent installer switch between the installer name and description that the user can double-click to edit. But I also want this script to plug in it's best switch suggestion by default so the user doesn't have to edit each software individually. Just trying to make things easier, overall.

The idea about 32/64 bit installers is good and I implemented such a thing on my Mp3Encoder software with the FFMpeg installer. Before user clicked a link to download an installer, it would suggest downloading the best installer for their system. You brought up a good point, that 64 bit installers cannot install on 32 bit system, but 32 can install on 64, but maybe you should download a better version of the software if you can. The same thing could apply to Win10 vs Win7. I have seen some software that rejects Win7 because it's too old.

Once again, thank you for your suggestions. I don't think either of them would be hard to implement. And they are great ideas, and I appreciate them. I will have to work on the bugs that are crashing the current version and then work on future versions.

 

Link to comment
Share on other sites

  • 3 months later...

I fixed the bug in version 1.2a, or at least it is working on my VM. Hopefully, I will get some time to implement some new features and I would really like a better way of configuring the software and I want to make the installer detection to be automatic instead of having to click the button every time. This isn't a major update, but it's the most up-to-date so far.

#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=gnome_app_install.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Array.au3>
#include <File.au3>
#include <FileConstants.au3>
#include <GDIPlus.au3>
#include <GUIConstants.au3>
#include <GuiTab.au3>
#include <GuiListView.au3>
#include <GuiMenu.au3>
#include <ProgressConstants.au3>
#include <String.au3>

Global $fIniConfig = @ScriptDir & "\Config.ini"
Global $sSWDir = @ScriptDir & "\Software\"
Global $sVersion = "1.2a"
Global $sAllSwitches = "-s|/silent|/verysilent|/sp- /silent /norestart|/verysilent /norestart|/S|/S /NCRC|/passive|/passive /norestart|/u|/u /z|/q|/q /r:n|/q:a|/qb|/qn|/q:a /r:n|/S|/s"
Global $sAllInstallers = "Ghost Installer|Inno Setup|InstallShield|Microsoft Hotfix Package|MSI Package|Nullsoft|Wise Installer"
Global $cDummy, $sSWDblClk
; Main GUI
$Form1 = GUICreate("Software Installer", 633, 451)
$cDummy = GUICtrlCreateDummy()
$Tab1 = GUICtrlCreateTab(16, 8, 601, 377)
$TabSheet1 = GUICtrlCreateTabItem("Audio/Video/Photo")
$ListView1 = GUICtrlCreateListView("Software Name|Description", 24, 40, 582, 334)
_GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES))
GUICtrlSendMsg(-1, 0x101E, 0, 200)
GUICtrlSendMsg(-1, 0x101E, 1, 375)
$TabSheet2 = GUICtrlCreateTabItem("System Tools")
$ListView2 = GUICtrlCreateListView("Software Name|Description", 24, 40, 578, 334)
_GUICtrlListView_SetExtendedListViewStyle($ListView2, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES))
GUICtrlSendMsg(-1, 0x101E, 0, 200)
GUICtrlSendMsg(-1, 0x101E, 1, 375)
$TabSheet3 = GUICtrlCreateTabItem("Internet")
$ListView3 = GUICtrlCreateListView("Software Name|Description", 24, 40, 578, 334)
_GUICtrlListView_SetExtendedListViewStyle($ListView3, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES))
GUICtrlSendMsg(-1, 0x101E, 0, 200)
GUICtrlSendMsg(-1, 0x101E, 1, 375)
$TabSheet4 = GUICtrlCreateTabItem("Games")
$ListView4 = GUICtrlCreateListView("Software Name|Description", 24, 40, 578, 334)
_GUICtrlListView_SetExtendedListViewStyle($ListView4, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES))
GUICtrlSendMsg(-1, 0x101E, 0, 200)
GUICtrlSendMsg(-1, 0x101E, 1, 375)
$TabSheet5 = GUICtrlCreateTabItem("Miscellaneous")
$ListView5 = GUICtrlCreateListView("Software Name|Description", 24, 40, 578, 334)
_GUICtrlListView_SetExtendedListViewStyle($ListView5, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES))
GUICtrlSendMsg(-1, 0x101E, 0, 200)
GUICtrlSendMsg(-1, 0x101E, 1, 375)
$TabSheet6 = GUICtrlCreateTabItem("Patches/Updates")
$ListView6 = GUICtrlCreateListView("Software Name|Description", 24, 40, 578, 334)
_GUICtrlListView_SetExtendedListViewStyle($ListView6, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES))
GUICtrlSendMsg(-1, 0x101E, 0, 200)
GUICtrlSendMsg(-1, 0x101E, 1, 375)
$TabSheet7 = GUICtrlCreateTabItem("Productivity")
$ListView7 = GUICtrlCreateListView("Software Name|Description", 24, 40, 578, 334)
_GUICtrlListView_SetExtendedListViewStyle($ListView7, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES))
GUICtrlSendMsg(-1, 0x101E, 0, 200)
GUICtrlSendMsg(-1, 0x101E, 1, 375)
GUICtrlCreateTabItem("") ; This ends the tab item creation
$g1Checkbox1 = GUICtrlCreateCheckbox("Prompt to edit software installation order", 16, 400, 220, 17)
;~ GUICtrlSetState(-1, $GUI_CHECKED) ; Enable this if you want.
$g1Button1 = GUICtrlCreateButton("Install Selected Software", 398, 395, 219, 25, 0)
$MenuItem1 = GUICtrlCreateMenu("File")
$MenuItem1a = GUICtrlCreateMenuItem("Select All", $MenuItem1)
$MenuItem2 = GUICtrlCreateMenuItem("Unselect All", $MenuItem1)
$MenuItem3 = GUICtrlCreateMenuItem("Exit", $MenuItem1)
$MenuItem4 = GUICtrlCreateMenu("Settings")
$MenuItem5 = GUICtrlCreateMenuItem("Edit Software Configuration", $MenuItem4)
$MenuItem6 = GUICtrlCreateMenu("Help")
$MenuItem7 = GUICtrlCreateMenuItem("Help Topics", $MenuItem6)
$MenuItem8 = GUICtrlCreateMenuItem("About", $MenuItem6)

GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")

GUISetState(@SW_SHOW)

$aSoftwareList = _FileListToArrayRec(@ScriptDir & "\Software", "*.exe;*.msi;*.msu", 1, 1) ; List all software in Software folder.
If NOT IsArray ($aSoftwareList) Then ; Easy fix for program crashing if no software is in the Software folder.
    If NOT FileExists(@ScriptDir & "\Software") Then
        DirCreate (@ScriptDir & "\Software")
    EndIf
    MsgBox(262144, "Error", "No software installers found in the Software folder." & @CRLF & "This program cannot function without any software installers." & @CRLF & "Add some to the folder and restart the program.")
    Exit
EndIf

For $i = 1 To 5 ; Add columns for other data.
    _ArrayColInsert($aSoftwareList, 1)
Next
Global $aUnconfiguredSW[$aSoftwareList[0][0]+1][5]
$aUnconfiguredSW[0][0] = 0
_CheckForNewSoftware($aSoftwareList)
If $aUnconfiguredSW[0][0] > 0 Then ; Get a list of all software that has not been configured.
    $iQueryUser = _QueryUser()
    If $iQueryUser = 1 Then
        _SWConfiguration()
    EndIf
EndIf
_Populate() ; Loads the software in the Software folder into the various lists.

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE ; Button: Exit
            Exit
        Case $cDummy
            _SWConfiguration()

        Case $g1Button1 ; Button: Install Selected Software
            _InstallSelectedSoftware()
        Case $MenuItem1a ; Menu: File > Select All
            _SelectAll(True)
        Case $MenuItem2 ; Menu: File > Unselect All
            _SelectAll(False)
        Case $MenuItem3 ; Menu: Exit
            Exit
        Case $MenuItem5 ; Menu: Edit Software Configuration
            _SWConfiguration()
        Case $MenuItem7 ; Menu: Help
            _HelpTopics()
        Case $MenuItem8 ; Menu: About
            _About()
    EndSwitch
WEnd

Func _Populate()
    ; Find all files in the Software folder and populate the tabs with the installers.
    For $i = 1 To 7 ; Fill out the master array with data
        _GUICtrlListView_DeleteAllItems(Eval("ListView" & $i))
    Next
    For $i = 1 To $aSoftwareList[0][0]
        $sDisplayName = IniRead($fIniConfig, $aSoftwareList[$i][0], "DisplayName", $aSoftwareList[$i][0])
        If $sDisplayName = "" Then
            $sDisplayName = $aSoftwareList[$i][0]
        EndIf
        $sCategory = IniRead($fIniConfig, $aSoftwareList[$i][0], "Category", "")
        If $sCategory = "" Then
            $sCategory = 5
        EndIf
        $sDescription = IniRead($fIniConfig, $aSoftwareList[$i][0], "Description", "")
        $checked = IniRead($fIniConfig,$aSoftwareList[$i][0],"IsDefault", "")
        $aSoftwareList[$i][1] = $sDisplayName
        $aSoftwareList[$i][2] = $sCategory
        $aSoftwareList[$i][3] = $sDescription
        $aSoftwareList[$i][4] = $checked
    Next

    For $i = 1 To $aSoftwareList[0][0] ; Populate the tabs with items
        $iCategory = IniRead($fIniConfig, $aSoftwareList[$i][0], "Category", 5)
        $sDoNotShow = IniRead($fIniConfig, $aSoftwareList[$i][0], "DoNotShow", 0)
        If $sDoNotShow <> 1 Then
            GUICtrlCreateListViewItem($aSoftwareList[$i][1] & "|" & $aSoftwareList[$i][3], (Eval("ListView" & $iCategory)))
            If $aSoftwareList[$i][4] = 1 Then
                $iI = _GUICtrlListView_FindText((Eval("ListView" & $iCategory)), $aSoftwareList[$i][1])
                _GUICtrlListView_SetItemChecked((Eval("ListView" & $iCategory)), $iI, True)       ;Set checked radiobox of last found control
            EndIf
        EndIf
    Next
EndFunc   ;==>_Populate

Func _InstallSelectedSoftware()
    GUISetState(@SW_DISABLE, $Form1)
    Local $sExit = ""
    $Form4 = GUICreate("Installing Software", 600, 172)
    $g4Label1 = GUICtrlCreateLabel("Installing:", 16, 16, 148, 17)
    $g4Label2 = GUICtrlCreateLabel("", 16, 40, 570, 19)
    GUICtrlSetFont(-1, 10, 400, 0, "Arial Rounded MT Bold")
    GUICtrlSetColor(-1, 0x008080)
    $g4Label3 = GUICtrlCreateLabel("File Size:", 16, 64, 146, 17)
    $g4Label4 = GUICtrlCreateLabel("Total Progress:", 16, 112, 75, 17)
    $g4Progress1 = GUICtrlCreateProgress(16, 136, 570, 17)

    Local $aInstallList[$aSoftwareList[0][0] + 1][4]
    $iInstallListSize = 0
    For $i = 1 To 7 ; Go through the 7 tabs on main GUI
        $iItemCount = _GUICtrlListView_GetItemCount(Eval("ListView" & $i))
        For $j = 1 To $iItemCount
            $vItemChecked = _GUICtrlListView_GetItemChecked(Eval("ListView" & $i), $j - 1)
            If $vItemChecked = TRUE Then
                $iInstallListSize += 1
                $aInstallList[0][0] = $iInstallListSize
                $sItemName = _GUICtrlListView_GetItemText(Eval("ListView" & $i), $j - 1) ; Problem is here - well maybe... Searches for text on screen. Need to search for installer name.
                $iArrayPos = _ArraySearch($aSoftwareList, $sItemName, Default, Default, Default, Default, Default, 1)
                $sSWInstaller = $aSoftwareList[$iArrayPos][0]
                $sSwitch = IniRead($fIniConfig, $sSWInstaller, "Switch", "")
                $aInstallList[$iInstallListSize][0] = $sSWDir & $sSWInstaller
                $aInstallList[$iInstallListSize][1] = $sSwitch
                $aInstallList[$iInstallListSize][2] = $sItemName
                $aInstallList[$iInstallListSize][3] = $sSWInstaller

            EndIf
        Next
    Next

    ReDim $aInstallList[$aInstallList[0][0] + 1][4]
    $iInstallOrder = GUICtrlRead($g1Checkbox1)
    If $iInstallOrder = 1 Then ; If the user wants to alter installation order, this pulls up the Gui.
        $aInstallList = _InstallOrder($aInstallList)
    EndIf

    GUISetState(@SW_SHOW, $Form4) ; The Installing Software screen has been hidden until now.

    For $i = 1 To $aInstallList[0][0] ; Set info into Gui and install the software.
        GUICtrlSetData($g4Label1, "Installing: " & $i & " of " & $aInstallList[0][0])
        GUICtrlSetData($g4Label2, $aInstallList[$i][2]) ; Name of software

        $sSWName = $aInstallList[$i][3] ; This was the problem - fed the easy to read name to the installer instead of the actual installer name.

        ; Make a list of pre-install software, selected software and post-install software

        ; File locations
        $sSWLoc1 = IniRead($fIniConfig, $sSWName, "SWLoc1", "")
        $sSWLoc2 = IniRead($fIniConfig, $sSWName, "SWLoc2", "")
        $sSWLoc3 = $aInstallList[$i][0] ; The selected software from the main screen
        $sSWLoc4 = IniRead($fIniConfig, $sSWName, "SWLoc3", "") ; Because I'm inserting the main software at position 3, I am offsetting the $SWLoc number +1 - $sSWLoc4 is for ini reading of "SWLoc3". Same goes for other entries after 2/3.
        $sSWLoc5 = IniRead($fIniConfig, $sSWName, "SWLoc4", "")

        ; File switches
        $sSWSw1 = IniRead($fIniConfig, $sSWName, "SwSw1", "")
        $sSWSw2 = IniRead($fIniConfig, $sSWName, "SwSw2", "")
        $sSwsw3 = $aInstallList[$i][1] ; Switch for the selected software from the main screen
        $sSWSw4 = IniRead($fIniConfig, $sSWName, "SwSw3", "")
        $sSWSw5 = IniRead($fIniConfig, $sSWName, "SwSw4", "")

        ; File descriptions
        $sSWDs1 = "Pre-Installing Software #1"
        $aSWDs1 = StringSplit($sSWLoc1, "\")
        If IsArray($aSWDs1) Then
            $sSWDs1 = "Pre-Installing Software #1 [ " & $aSWDs1[$aSWDs1[0]] & " ]"
        EndIf
        $sSWDs2 = "Pre-Installing Software #2"
        $aSWDs2 = StringSplit($sSWLoc2, "\")
        If IsArray($aSWDs2) Then
            $sSWDs2 = "Pre-Installing Software #2 [ " & $aSWDs2[$aSWDs2[0]] & " ]"
        EndIf
        $sSWDs3 = $aInstallList[$i][2] ; Description of the selected software from the main screen
        $aSWDs3= StringSplit($sSWDs3, "\")
        If IsArray($aSWDs3) Then
            $sSWDs3 = $aSWDs3[$aSWDs3[0]]
        EndIf
        $sSWDs4 = "Post-Installing Software #1"
        $aSWDs4 = StringSplit($sSWLoc4, "\")
        If IsArray($aSWDs4) Then
            $sSWDs4 = "Post-Installing Software #1 [ " & $aSWDs4[$aSWDs4[0]] & "] "
        EndIf
        $sSWDs5 = "Post-Installing Software #2"
        $aSWDs5 = StringSplit($sSWLoc5, "\")
        If IsArray($aSWDs5) Then
            $sSWDs5 = "Post-Installing Software #2 [ " & $aSWDs5[$aSWDs5[0]] & " ]"
        EndIf

        ; Make a blank array to put in pre-install software, the selected software and post-install software to be installed
        Local $aSWQueue[5][3]
        $sArraySize = 0
        For $j = 1 To 5
            If Eval ("sSWLoc" & $j) <> "" Then
                $aSWQueue[$sArraySize][0] = Eval ("sSWLoc" & $j) ; Software location
                $aSWQueue[$sArraySize][1] = Eval ("sSWSw" & $j) ; Software switch
                $aSWQueue[$sArraySize][2] = Eval ("sSWDs" & $j) ; Software description / filename
                $sArraySize += 1
            EndIf
        Next

        ; Install the pre-install software, selected software and post-install software.
        For $j = 0 To $sArraySize - 1 ; Zero-based to accomodate the arrays.
            GUICtrlSetData($g4Label2, $aSWQueue[$j][2]) ; Set name / description of software on progress window
            GUICtrlSetData($g4Label3, "File Size: " & Round(FileGetSize($aSWQueue[$j][0])/1024000, 1) & " MB")
            $sInstallString = '"' & $aSWQueue[$j][0] & '" ' & $aSWQueue[$j][1]
            If StringRight($aSWQueue[$j][0], 4) = ".msi" Then
                Run("msiexec /i " & $sInstallString)
            ElseIf StringRight($aSWQueue[$j][0], 4) = ".msu" Then
                ShellExecuteWait($aSWQueue[$j][0], $aSWQueue[$j][1])
            Else
                If StringInStr($aSWQueue[$j][0], "7z") Then ; Special exception for installing 7-Zip
                    RegDelete("HKEY_CURRENT_USER\Software\7-Zip", "Path")
                    RegDelete("HKEY_CURRENT_USER\Software\7-Zip", "Path32")
                    RegDelete("HKEY_CURRENT_USER\Software\7-Zip", "Path64")
                    $sInstallSwitch = '/S /D="' & @HomeDrive & '\Program Files\7-Zip"'
                    RunWait('"' & $aSWQueue[$j][0] & '" ' & $sInstallSwitch)
                Else ; Normally install software with the specified switch.
                    RunWait('"' & $aSWQueue[$j][0] & '" ' & $aSWQueue[$j][1])
                EndIf
            EndIf
        Next
        GUICtrlSetData($g4Progress1, $i/$aInstallList[0][0]*100)
    Next
    GUISetState(@SW_ENABLE, $Form1)
    GUIDelete($Form4)
    _SelectAll(False)
EndFunc

Func _SelectAll($TF) ; Sending TRUE or FALSE to select all or unselect all.
    For $i = 1 To 7
        $iItemCount = _GUICtrlListView_GetItemCount(Eval("ListView" & $i))
        For $j = 1 To $iItemCount
            _GUICtrlListView_SetItemChecked(Eval("ListView" & $i), $j - 1, $TF)
        Next
    Next
EndFunc   ;==>_SelectAll

Func _CheckForNewSoftware($aSoftwareList)
    Local $aConfigFileSW = IniReadSectionNames($fIniConfig)
        $iArrayPos = 1
        For $i = 1 To $aSoftwareList[0][0]
            If _ArraySearch($aConfigFileSW, $aSoftwareList[$i][0]) < 1 Then
                $aUnconfiguredSW[$iArrayPos][0] = $aSoftwareList[$i][0]
                $aUnconfiguredSW[0][0] = $iArrayPos
                $iArrayPos += 1
            EndIf
        Next
EndFunc

Func _SWConfiguration()
    GUISetState(@SW_DISABLE, $Form1)
    $Form2 = GUICreate("Configure Software", 620, 520)
    Global $g2List = GUICtrlCreateList("", 8, 24, 602, 218)
    $g2Checkbox1 = GUICtrlCreateCheckbox("Show All Software", 8, 240, 121, 17)
    $g2Label1 = GUICtrlCreateLabel("Display Name For Software:", 8, 264, 250, 17)
    $g2Input1 = GUICtrlCreateInput("", 8, 280, 250, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $g2Label2 = GUICtrlCreateLabel("Installer Type (optional):", 8, 320, 116, 17)
    $g2Combo1 = GUICtrlCreateCombo("", 8, 336, 170, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
    GUICtrlSetState(-1, $GUI_DISABLE)
    $g2Button4 = GUICtrlCreateButton("Detect", 185, 335, 75, 23)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $g2Label3 = GUICtrlCreateLabel("Silent Switch To Be Used:", 8, 376, 128, 17)
    $g2Combo2 = GUICtrlCreateCombo("", 8, 392, 250, 25)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $g2Label4 = GUICtrlCreateLabel("Software Description (optional):", 300, 264, 250, 17)
    $g2Input2 = GUICtrlCreateInput("", 300, 280, 250, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $g2Label5 = GUICtrlCreateLabel("Category:", 300, 320, 128, 17)
    $g2Combo3 = GUICtrlCreateCombo("", 300, 336, 250, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
    GUICtrlSetState(-1, $GUI_DISABLE)
    $g2Label6 = GUICtrlCreateLabel("Double-Click Each Software To Configure. When Finished, Click The Save Button", 8, 6, 391, 17)
    $g2Label7 = GUICtrlCreateLabel("Editing: ", 8, 240, 602, 17)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    GUICtrlSetColor(-1, 0x008000)
    GUICtrlSetBkColor(-1, 0xC0DCC0)
    GUICtrlSetState(-1, $GUI_HIDE)
    $g2Checkbox2 = GUICtrlCreateCheckbox("This Software Defaults To Selected On Main GUI", 8, 460, 280, 17)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $g2Checkbox3 = GUICtrlCreateCheckbox("Hide This Item On Main GUI", 8, 490, 280, 17)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $g2Checkbox4 = GUICtrlCreateCheckbox("Run Pre-Install/Post-Install Software", 300, 392)
    GUICtrlSetTip(-1, "(Optional) This option allows you to run software before your installer or software/registy entries afterwards.")
    GUICtrlSetState(-1, $GUI_DISABLE)
    $g2Button3 = GUICtrlCreateButton("Configure", 500, 392, 80, 25)
    GUICtrlSetState(-1, $GUI_HIDE)
    $g2Button1 = GUICtrlCreateButton("Edit A Different Software", 300, 460, 160, 27, $WS_GROUP)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $g2Button2 = GUICtrlCreateButton("Save Data", 480, 460, 100, 27, $WS_GROUP)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUISetState(@SW_SHOW)
    _ClearAndSetInputs($g2List, $g2Button3, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input1, $g2Input2, $g2Label7, $g2Checkbox1, $g2Checkbox2, $g2Checkbox3, $g2Checkbox4, $aUnconfiguredSW)
    Global $idDummy = GUICtrlCreateDummy()
    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

    If $sSWDblClk <> "" Then

        GUICtrlSendToDummy($idDummy)

    EndIf

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                $sEditMode = GUICtrlGetState($g2Button2) ; If the save button is active, then assume user has not saved data. Prompt if they still want to exit.
                If $sEditMode = 80 Then
                    $sExit = MsgBox(262148, "Attention", "You have unsaved data. Do you want to close this window without saving?")
                    If $sExit = 6 Then ; If they want to exit without saving, do it.
                        GUISetState(@SW_ENABLE, $Form1)
                        GUIDelete($Form2)
                        _Populate()
                        ExitLoop
                    EndIf
                Else ; If the save button is not active, there is nothing to save, so exit.
                    GUISetState(@SW_ENABLE, $Form1)
                    GUIDelete($Form2)
                    _Populate()
                    ExitLoop
                EndIf
            Case $idDummy ; Something on the list has been double-clicked or double-clicked on the main gui. Change to edit mode for the selected software.
                _ClearAndSetInputs($g2List, $g2Button3, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input1, $g2Input2, $g2Label7, $g2Checkbox1, $g2Checkbox2, $g2Checkbox3, $g2Checkbox4, $aUnconfiguredSW)
                Local $sSWEditing
                If $sSWDblClk <> "" Then
                    $sSWEditing = $sSWDblClk
                Else
                    $sSWEditing = GUICtrlRead($idDummy)
                EndIf
                GUICtrlSetData($g2Label7, "Editing: " & $sSWEditing)
                $sDesc = IniRead($fIniConfig, $sSWEditing, "Description", "")
                $sFullSwitches = "-s|/silent|/verysilent|/sp- /silent /norestart|/verysilent /norestart|/S|/S /NCRC|/passive|/passive /norestart|/u|/u /z|/q|/q /r:n|/q:a|/qb|/qn|/q:a /r:n|/S|/s"
                $sSwitch = IniRead($fIniConfig, $sSWEditing, "Switch", $sFullSwitches)
                Local $aCategories[8] = ["7","Audio/Video/Photo", "System Tools", "Internet", "Games", "Miscellaneous", "Patches/Updates", "Productivity"]
                $iCategory = IniRead($fIniConfig, $sSWEditing, "Category", "5")
                $sCategory = $aCategories[$iCategory]
                $sDisplayName = IniRead($fIniConfig, $sSWEditing, "DisplayName", "")
                $sIsDefault = IniRead($fIniConfig, $sSWEditing, "IsDefault", "")
                If $sIsDefault = 1 Then
                    GUICtrlSetState($g2Checkbox2, $GUI_CHECKED)
                EndIf
                $sDoNotShow = IniRead($fIniConfig, $sSWEditing, "DoNotShow", 0)
                If $sDoNotShow = 1 Then
                    GUICtrlSetState($g2Checkbox3, $GUI_CHECKED)
                EndIf
                GUICtrlSetData($g2Input1, $sDisplayName)
                GUICtrlSetData($g2Combo2, $sSwitch, $sSwitch)
                GUICtrlSetData($g2Input2, $sDesc)
                GUICtrlSetData($g2Combo3, $sCategory)
                GUICtrlSetData($g2List, "")
                GUICtrlSetData($g2List, $sSWEditing)
                $sRunPostInstall = IniRead($fIniConfig, $sSWEditing, "CBPrePost", "Unchecked")
                If $sRunPostInstall = "Checked" Then
                    GUICtrlSetState($g2Checkbox4, $GUI_CHECKED)
                    GUICtrlSetState($g2Button3, $GUI_SHOW)
                EndIf
                $sSWDblClk = "" ; Resets the name of the software to prevent glitchs.
                _EnableDisableControls($g2Input1, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input2, $g2Button1, $g2Button2, $g2Button3, $g2Button4, $g2Checkbox1, $g2Checkbox2, $g2Checkbox3, $g2Checkbox4, $g2Label7, $g2List, 1) ; enable
            Case $g2Button1 ; Discard any unsaved data that has been entered and switch back to software selection mode.
                GUICtrlSetData($g2Button4, "Detect")
                _ClearAndSetInputs($g2List, $g2Button3, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input1, $g2Input2, $g2Label7, $g2Checkbox1, $g2Checkbox2, $g2Checkbox3, $g2Checkbox4, $aUnconfiguredSW)
                _EnableDisableControls($g2Input1, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input2, $g2Button1, $g2Button2, $g2Button3, $g2Button4, $g2Checkbox1, $g2Checkbox2, $g2Checkbox3, $g2Checkbox4, $g2Label7, $g2List, 0)
            Case $g2Combo1
                _SetSwitchData($g2Combo1, $g2Combo2, $g2Combo3)
            Case $g2Checkbox1 ; Toggles between unconfigured software to all software (configured & unconfigured).
                $iCBRead = GUICtrlRead($g2Checkbox1)
                If $iCBRead = 1 Then
                    _ClearAndSetInputs($g2List, $g2Button3, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input1, $g2Input2, $g2Label7, $g2Checkbox1, $g2Checkbox2, $g2Checkbox3, $g2Checkbox4, $aUnconfiguredSW)
                Else
                    _ClearAndSetInputs($g2List, $g2Button3, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input1, $g2Input2, $g2Label7, $g2Checkbox1, $g2Checkbox2, $g2Checkbox3, $g2Checkbox4, $aUnconfiguredSW)
                EndIf
            Case $g2Button2 ; Save data and switch back to software selection mode.
                GUICtrlSetData($g2Button4, "Detect")
                $sCurrentSW = StringTrimLeft(GUICtrlRead($g2Label7), 9) ; Trim off the left wing "Editing: " to get the current software name.
                $sDesc = IniWrite($fIniConfig, $sCurrentSW, "Description", GUICtrlRead($g2Input2))
                $sSwitch = IniWrite($fIniConfig, $sCurrentSW, "Switch", GUICtrlRead($g2Combo2)) ; Having a problem with this line when saving switch data when in "all software" mode, or at least i think this is a problem.
                Local $aCategories[8] = ["7","Audio/Video/Photo", "System Tools", "Internet", "Games", "Miscellaneous", "Patches/Updates", "Productivity"]
                $sCategory = GUICtrlRead($g2Combo3)
                $iArrayPos = _ArraySearch($aCategories, $sCategory)
                IniWrite($fIniConfig, $sCurrentSW, "Category", $iArrayPos)
                $sDisplayName = IniWrite($fIniConfig, $sCurrentSW, "DisplayName", GUICtrlRead($g2Input1))
                $sRunPostInstall = IniWrite($fIniConfig, $sCurrentSW, "PostInstall", GUICtrlRead($g2Combo3))
                $sIsDefault = IniWrite($fIniConfig, $sCurrentSW, "IsDefault", GUICtrlRead($g2Checkbox2))
                $iArrayPos = _ArraySearch($aUnconfiguredSW, $sCurrentSW)
                If $iArrayPos > 0 Then
                    _ArrayDelete($aUnconfiguredSW, $iArrayPos)
                    $aUnconfiguredSW[0][0] -= 1
                EndIf
                $sDoNotShow = GUICtrlRead($g2Checkbox3)
                IniWrite($fIniConfig, $sCurrentSW, "DoNotShow", $sDoNotShow)
                $sCBRead = GUICtrlRead($g2Checkbox4)
                If $sCBRead = 1 Then
                    IniWrite($fIniConfig, $sCurrentSW, "CBPrePost", "Checked")
                Else
                    IniWrite($fIniConfig, $sCurrentSW, "CBPrePost", "Unchecked")
                EndIf
                GUICtrlSetData($g2Label7, "")
                _ClearAndSetInputs($g2List, $g2Button3, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input1, $g2Input2, $g2Label7, $g2Checkbox1, $g2Checkbox2, $g2Checkbox3, $g2Checkbox4, $aUnconfiguredSW)
                _EnableDisableControls($g2Input1, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input2, $g2Button1, $g2Button2, $g2Button3, $g2Button4, $g2Checkbox1, $g2Checkbox2, $g2Checkbox3, $g2Checkbox4, $g2Label7, $g2List, 0)
            Case $g2Checkbox4
                $sCBRead = GUICtrlRead($g2Checkbox4)
                If $sCBRead = 1 Then
                    GUICtrlSetState($g2Button3, $GUI_SHOW)
                Else
                    GUICtrlSetState($g2Button3, $GUI_HIDE)
                EndIf
            Case $g2Button3
                _PrePostInstallSoftware ($sSWEditing, $Form2)
            Case $g2Button4 ; Detect the installer type
                _GetInstallerType($sSWEditing, $g2Combo1, $g2Combo2, $g2Combo3, $g2Button4)
        EndSwitch
    WEnd
EndFunc

Func _GetInstallerType($sSWName, $Combo1, $Combo2, $Combo3, $Button)
    If StringRight($sSWName, 4) = ".msi" Then
        GUICtrlSetData($Combo1, "MSI Package")
        _SetSwitchData($Combo1, $Combo2, $Combo3)
    ElseIf StringRight($sSWName, 4) = ".msu" Then
        GUICtrlSetData($Combo1, "Microsoft Hotfix Package")
        _SetSwitchData($Combo1, $Combo2, $Combo3)
    Else
        $sFileName = @ScriptDir & "\Software\" & $sSWName
        $hFileOpen = FileOpen($sFileName)
        Local $sFileRead = FileRead($hFileOpen, 8000000) ; Only read the first 1 MB of the file for speed and prevent crashing. If installer type is in plain text, it will probably be in this section of the file.
        $sSearchStrings = "(496E6E6F205365747570|4E756C6C736F6674)" ;Inno Setup|Nullsoft
        $aMatch = StringRegExp($sFileRead, $sSearchStrings, 1)
        $sFileRead = ""
        FileClose($hFileOpen)
        $sTestMode = 0
        $sSwitchFound = 0
        If IsArray($aMatch) Then ; If a match is found, decode the hex to ascii and set that to the combo.
            $sDecoded = _HexToString($aMatch[0])
            GUICtrlSetData($Combo1, $sDecoded)
            _SetSwitchData($Combo1, $Combo2, $Combo3)
            $sSwitchFound = 1
        EndIf
        If  $sSwitchFound = 0 Then
            $sProdName = FileGetVersion($sFileName, $FV_PRODUCTNAME)
            If $sTestMode = 1 Then
                FileRecycle($sFileName)
                FileWrite("Installers.db", $sProdName & "|" & @CRLF)
            EndIf
            If $sProdName <> "" Then
                $sSilentSwitches = IniRead(@ScriptDir & "\Installers.db", $sProdName, "Switches", "")
                $sSilentSwitch = IniRead(@ScriptDir & "\Installers.db", $sProdName, "DefaultSwitch", "")
                $sProdName = "[ " & $sProdName & " ]"
                GUICtrlSetData($Combo1, "") ; Clear drop-down data to replenish it.
                GUICtrlSetData($Combo1, $sProdName, $sProdName)
                GUICtrlSetData($Combo2, "") ; Clear drop-down data to replenish it.
                GUICtrlSetData($Combo2, $sSilentSwitches, $sSilentSwitch)
            EndIf
        Else
            GUICtrlSetData($Button, "Unknown") ; If no match if found, set the button to "unknown" and disable it. It will get re-enabled on the next software selected.
            GUICtrlSetState($Button, $GUI_DISABLE)
        EndIf
    EndIf
EndFunc

Func _SetSwitchData($Combo1, $Combo2, $Combo3)
    $sInstaller = GUICtrlRead($Combo1)
    GUICtrlSetData($Combo2, "")
    If $sInstaller = "Ghost Installer" Then
        GUICtrlSetData($Combo2, "-s", "-s")
    ElseIf $sInstaller = "Inno Setup" Then
        GUICtrlSetData($Combo2, "/silent|/verysilent|/sp- /silent /norestart|/verysilent /norestart", "/verysilent /norestart")
    ElseIf $sInstaller = "InstallShield" Then
        GUICtrlSetData($Combo2, "/S|/S /NCRC", "/S")
    ElseIf $sInstaller = "Microsoft Hotfix Package" Then
        GUICtrlSetData($Combo2, "/passive|/passive /norestart|/quiet|/quiet /norestart|/u|/u /z|/q|/q /r:n|/q:a|/qb|/qn|/q:a /r:n", "/quiet /norestart")
        GUICtrlSetData($Combo3, "Patches/Updates")
    ElseIf $sInstaller = "MSI Package" Then
        GUICtrlSetData($Combo2, "/qb|/qn", "/qn")
    ElseIf $sInstaller = "Nullsoft" Then
        GUICtrlSetData($Combo2, "/S", "/S")
    ElseIf $sInstaller = "Wise Installer" Then
        GUICtrlSetData($Combo2, "/s", "/s")
    Else
        GUICtrlSetData($Combo2, $sAllSwitches)
    EndIf
EndFunc

Func _EnableDisableControls($g2Input1, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input2, $g2Button1, $g2Button2, $g2Button3, $g2Button4, $g2Checkbox1, $g2Checkbox2, $g2Checkbox3, $g2Checkbox4, $g2Label7, $g2List, $01)
    GUICtrlSetState($g2Input1, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE)
    GUICtrlSetState($g2Combo1, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE)
    GUICtrlSetState($g2Combo2, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE)
    GUICtrlSetState($g2Combo3, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE)
    GUICtrlSetState($g2Input2, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE)
    GUICtrlSetState($g2Checkbox1, ($01 = 1) ? $GUI_HIDE : $GUI_SHOW)
    GUICtrlSetState($g2Checkbox2, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE)
    GUICtrlSetState($g2Checkbox3, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE)
    GUICtrlSetState($g2Checkbox4, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE)
    GUICtrlSetState($g2Button1, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE)
    GUICtrlSetState($g2Button2, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE)
    GUICtrlSetState($g2Button3, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE)
    GUICtrlSetState($g2Button4, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE)
    GUICtrlSetState($g2Label7, ($01 = 1) ? $GUI_SHOW : $GUI_HIDE)
    GUICtrlSetState($g2List, ($01 = 1) ? $GUI_DISABLE : $GUI_ENABLE)
EndFunc

Func _ClearAndSetInputs($g2List, $g2Button3, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input1, $g2Input2, $g2Label7, $g2Checkbox1, $g2Checkbox2, $g2Checkbox3, $g2Checkbox4, $aSW, $iSWList = 0)
    GUICtrlSetData($g2List, "")
    GUICtrlSetData($g2Input1, "")
    GUICtrlSetData($g2Input2, "")
    GUICtrlSetData($g2Combo1, "")
    GUICtrlSetData($g2Combo2, "")
    GUICtrlSetData($g2Combo3, "")
    GUICtrlSetData($g2Combo1, $sAllInstallers)
    _SetSwitchData($g2Combo1, $g2Combo2, $g2Combo3)
    GUICtrlSetData($g2Combo3, "Audio/Video/Photo|System Tools|Internet|Games|Miscellaneous|Patches/Updates|Productivity", "Miscellaneous")
    GUICtrlSetState ($g2Checkbox2, $GUI_UNCHECKED)
    $iCBRead = GUICtrlRead($g2Checkbox1)
    If $iCBRead = 1 Then
        If IsArray($aSoftwareList) Then
            For $i = 1 To $aSoftwareList[0][0]
                GUICtrlSetData($g2List, $aSoftwareList[$i][0])
            Next
        EndIf
    Else
        If IsArray($aUnconfiguredSW) Then
            For $i = 1 To $aUnconfiguredSW[0][0]
                GUICtrlSetData($g2List, $aUnconfiguredSW[$i][0])
            Next
        EndIf
    EndIf
    GUICtrlSetState($g2Checkbox4, $GUI_UNCHECKED)
    GUICtrlSetState($g2Button3, $GUI_HIDE)
EndFunc

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    Local $hWndFrom, $iIDFrom, $iCode, $hWndEdit
    $hWndFrom = $lParam
    $iIDFrom = _WinAPI_LoWord($wParam)
    $iCode = _WinAPI_HiWord($wParam)
    If $iCode = $LBN_DBLCLK AND $iIDFrom = $g2List Then
        $sClicked = GUICtrlRead($g2List)
        GUICtrlSendToDummy($idDummy, $sClicked)
    EndIf
EndFunc

Func _InstallOrder($aInstallList)
    GUISetState(@SW_DISABLE, $Form1)
    $Form5 = GUICreate("Installation Order", 423, 292)
    $g5Label1 = GUICtrlCreateLabel("Highlight software and click the up and down arrows to change order of installation", 16, 3, 393, 17)
    $g5List1 = GUICtrlCreateList("", 16, 24, 321, 253, $LBS_NOTIFY)
    $g5Button1 = GUICtrlCreateButton(ChrW(8593), 344, 112, 35, 25, $WS_GROUP)
    $g5Button2 = GUICtrlCreateButton(ChrW(8595), 344, 144, 35, 25, $WS_GROUP)
    $g5Button3 = GUICtrlCreateButton("Done", 351, 251, 59, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    For $i = 1 To $aInstallList[0][0]
        GUICtrlSetData($g5List1, $aInstallList[$i][3])
    Next

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                GUISetState(@SW_ENABLE, $Form1)
                GUIDelete($Form5)
                Return $aInstallList
                ExitLoop
            Case $g5Button1
                $sRead = GUICtrlRead($g5List1)
                If $sRead <> "" Then
                    $iArrayPos = _ArraySearch($aInstallList, $sRead, Default, Default, Default,Default,Default, 3)
                    If $iArrayPos > 1 Then
                        _ArraySwap($aInstallList, $iArrayPos, $iArrayPos - 1)
                    EndIf
                    GUICtrlSetData($g5List1, "")
                    For $i = 1 To $aInstallList[0][0]
                        GUICtrlSetData($g5List1, $aInstallList[$i][3])
                    Next
                EndIf
            Case $g5Button2
                $sRead = GUICtrlRead($g5List1)
                If $sRead <> "" Then
                    $iArrayPos = _ArraySearch($aInstallList, $sRead, Default, Default, Default,Default,Default, 3)
                    If $iArrayPos < $aInstallList[0][0] Then
                        _ArraySwap($aInstallList, $iArrayPos, $iArrayPos + 1)
                    EndIf
                    GUICtrlSetData($g5List1, "")
                    For $i = 1 To $aInstallList[0][0]
                        GUICtrlSetData($g5List1, $aInstallList[$i][3])
                    Next
                EndIf
            Case $g5Button3
                GUISetState(@SW_ENABLE, $Form1)
                GUIDelete($Form5)
                Return $aInstallList
                ExitLoop
        EndSwitch
    WEnd
EndFunc

Func _QueryUser()
    $iShowConfigSWDiag = IniRead($fIniConfig, "Settings", "ShowConfigSWDiag", 4)
    If $iShowConfigSWDiag = 4 Then
        GUISetState(@SW_DISABLE, $Form1)
        $iStyle2 = BitOr( $WS_CAPTION, $WS_POPUP, $WS_SYSMENU)
        $Form6 = GUICreate("Attention", 423, 119, Default, Default, $iStyle2)
        $g6Label1 = GUICtrlCreateLabel("You have unconfigured software. Do you want to configure them now?", 32, 32, 338, 17)
        $g6Button1 = GUICtrlCreateButton("Yes", 184, 72, 99, 25, $WS_GROUP)
        $g6Button2 = GUICtrlCreateButton("No", 296, 72, 99, 25, $WS_GROUP)
        $g6Checkbox1 = GUICtrlCreateCheckbox("Do not ask again", 32, 80, 121, 17)
        GUISetState()
        $g6ExitButton = _GUICtrlMenu_GetSystemMenu($Form6)
        _GUICtrlMenu_EnableMenuItem($g6ExitButton, $SC_CLOSE, 1, False)

        While 1
            $nMsg = GUIGetMsg()
            Switch $nMsg
                Case $g6Button1
                    $iCBRead = GUICtrlRead($g6Checkbox1)
                    If $iCBRead = 1 Then
                        IniWrite($fIniConfig, "Settings", "ShowConfigSWDiag", $iCBRead)
                    EndIf
                    GUISetState(@SW_ENABLE, $Form1)
                    GUIDelete($Form6)
                    Return 1
                    ExitLoop
                Case $g6Button2
                    $iCBRead = GUICtrlRead($g6Checkbox1)
                    If $iCBRead = 1 Then
                        IniWrite($fIniConfig, "Settings", "ShowConfigSWDiag", $iCBRead)
                    EndIf
                    GUISetState(@SW_ENABLE, $Form1)
                    GUIDelete($Form6)
                    Return 0
                    ExitLoop
            EndSwitch
        WEnd
    EndIf
EndFunc

Func _About()
    GUISetState(@SW_DISABLE, $Form1)
    Local $Form3, $hGraphic
    Local Const $iWidth = 400, $iHeight = 150, $iBgColor = 0x303030
    $Form3 = GUICreate("About Software Installer", 400, 300)
    GUISetBkColor($iBgColor, $Form3)
    GUISetState(@SW_SHOW)
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($Form3)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFEE88BB)
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($Form3)
    _GDIPlus_GraphicsFillRect($hGraphic, 0, 150, 400, 300, $hBrush)

    $g3Label1 = GUICtrlCreateLabel("Software Installer", 48, 16, 304, 44)
    GUICtrlSetFont(-1, 26, 400, 0, "Arial Rounded MT Bold")
    GUICtrlSetColor(-1, 0xC0C0C0)
    $g3Label2 = GUICtrlCreateLabel("Version " & $sVersion, 48, 56, 100, 22)
    GUICtrlSetFont(-1, 12, 400, 0, "Arial")
    GUICtrlSetColor(-1, 0xC0C0C0)
    $g3Label3 = GUICtrlCreateLabel("Click here to go to the home page for this software", 48, 240, 300, 21)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    GUICtrlSetColor(-1, 0x000080)
    GUICtrlSetBkColor(-1, 0x434E54)
    GUICtrlSetCursor (-1, 0)
    $g3Label4 = GUICtrlCreateLabel("Scripted with AutoIt", 48, 200, 115, 20)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    GUICtrlSetColor(-1, 0x808080)
    $g3Label5 = GUICtrlCreateLabel("This software is designed to help automate unattended and/or silent software installation.", 56, 96, 282, 40)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    GUICtrlSetColor(-1, 0x00FFFF)

    While 1
        $nmsg = GUIGetMsg()
        Switch $nMsg
            Case $g3Label3
                ShellExecute ("https://www.autoitscript.com/forum/topic/143730-software-installer/")
            Case $GUI_EVENT_CLOSE
                _GDIPlus_BrushDispose($hBrush)
                _GDIPlus_GraphicsDispose($hGraphic)
                _GDIPlus_Shutdown()
                GUISetState(@SW_ENABLE, $Form1)
                GUIDelete($Form3)
                ExitLoop
        EndSwitch
    WEnd
EndFunc

Func _PrePostInstallSoftware($sSWName, $Form2)
    GUISetState(@SW_DISABLE, $Form2)
    $g6Form = GUICreate("Pre And Post Install Software For: " & $sSWName, 552, 424)
    $g6Group1 = GUICtrlCreateGroup("Pre-Install Software", 16, 16, 513, 177)
    GUICtrlSetTip(-1, "These software will run BEFORE installing the software you are configuring (" & $sSWName & ").")
    $g6Label1 = GUICtrlCreateLabel("Software #1", 24, 40, 62, 17)
    $g6Input1 = GUICtrlCreateInput("", 24, 56, 409, 21)
    $g6Button1 = GUICtrlCreateButton("Select", 440, 56, 75, 23, $WS_GROUP)
    $g6Label2 = GUICtrlCreateLabel("Software #2", 24, 120, 62, 17)
    $g6Input2 = GUICtrlCreateInput("", 24, 136, 409, 21)
    $g6Button2 = GUICtrlCreateButton("Select", 440, 136, 75, 23, $WS_GROUP)
    $g6Label5 = GUICtrlCreateLabel("Switch", 224, 80, 36, 17)
    $g6Combo1 = GUICtrlCreateCombo("", 264, 80, 169, 25)
    GUICtrlSetData($g6Combo1, $sAllSwitches)
    $g6Label6 = GUICtrlCreateLabel("Switch", 224, 160, 36, 17)
    $g6Combo2 = GUICtrlCreateCombo("", 264, 160, 169, 25)
    GUICtrlSetData($g6Combo2, $sAllSwitches)
    $g6Button6 = GUICtrlCreateButton("Detect", 440, 80, 75, 20, $WS_GROUP)
    $g6Button7 = GUICtrlCreateButton("Detect", 440, 160, 75, 20, $WS_GROUP)
    $g6Label9 = GUICtrlCreateLabel("Installer", 24, 80, 40, 17)
    $g6Combo5 = GUICtrlCreateCombo("", 72, 80, 145, 25)
    GUICtrlSetData(-1, $sAllInstallers)
    $g6Label10 = GUICtrlCreateLabel("Installer", 24, 160, 40, 17)
    $g6Combo6 = GUICtrlCreateCombo("", 72, 160, 145, 25)
    GUICtrlSetData(-1, $sAllInstallers)
    $g6Label13 = GUICtrlCreateLabel("Clear Data", 96, 39, 54, 16)
    GUICtrlSetColor(-1, 0x800080)
    GUICtrlSetCursor (-1, 0)
    $g6Label14 = GUICtrlCreateLabel("Clear Data", 96, 119, 54, 16)
    GUICtrlSetColor(-1, 0x800080)
    GUICtrlSetCursor (-1, 0)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $g6Group2 = GUICtrlCreateGroup("Post-Install Software", 16, 208, 513, 177)
    GUICtrlSetTip(-1, "These software will run AFTER installing the software you are configuring (" & $sSWName & ").")
    $g6Label3 = GUICtrlCreateLabel("Software #1", 24, 232, 62, 17)
    $g6Input3 = GUICtrlCreateInput("", 24, 248, 409, 21)
    $g6Button3 = GUICtrlCreateButton("Select", 440, 248, 75, 23, $WS_GROUP)
    $g6Label4 = GUICtrlCreateLabel("Software #2", 24, 312, 62, 17)
    $g6Input4 = GUICtrlCreateInput("", 24, 328, 409, 21)
    $g6Button4 = GUICtrlCreateButton("Select", 440, 328, 75, 23, $WS_GROUP)
    $g6Label7 = GUICtrlCreateLabel("Switch", 224, 272, 36, 17)
    $g6Combo3 = GUICtrlCreateCombo("", 264, 272, 169, 25)
    GUICtrlSetData($g6Combo3, $sAllSwitches)
    $g6Label8 = GUICtrlCreateLabel("Switch", 224, 352, 36, 17)
    $g6Combo4 = GUICtrlCreateCombo("", 264, 352, 169, 25)
    $g6Button8 = GUICtrlCreateButton("Detect", 440, 272, 75, 20, $WS_GROUP)
    $g6Button9 = GUICtrlCreateButton("Detect", 440, 352, 75, 20, $WS_GROUP)
    $g6Label11 = GUICtrlCreateLabel("Installer", 24, 272, 40, 17)
    $g6Combo7 = GUICtrlCreateCombo("", 72, 272, 145, 25)
    GUICtrlSetData(-1, $sAllInstallers)
    $g6Label12 = GUICtrlCreateLabel("Installer", 24, 352, 40, 17)
    $g6Combo8 = GUICtrlCreateCombo("", 72, 352, 145, 25)
    GUICtrlSetData(-1, $sAllInstallers)
    GUICtrlSetData($g6Combo4, $sAllSwitches)
    $g6Label15 = GUICtrlCreateLabel("Clear Data", 96, 231, 54, 16)
    GUICtrlSetColor(-1, 0x800080)
    GUICtrlSetCursor (-1, 0)
    $g6Label16 = GUICtrlCreateLabel("Clear Data", 96, 311, 54, 16)
    GUICtrlSetColor(-1, 0x800080)
    GUICtrlSetCursor (-1, 0)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $g6Button5 = GUICtrlCreateButton("Save Settings", 389, 392, 139, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)

    $sSWLoc1 = IniRead($fIniConfig, $sSWName, "SWLoc1", "")
    $sSWLoc2 = IniRead($fIniConfig, $sSWName, "SWLoc2", "")
    $sSWLoc3 = IniRead($fIniConfig, $sSWName, "SWLoc3", "")
    $sSWLoc4 = IniRead($fIniConfig, $sSWName, "SWLoc4", "")
    $sSWSw1 = IniRead($fIniConfig, $sSWName, "SwSw1", "")
    $sSWSw2 = IniRead($fIniConfig, $sSWName, "SwSw2", "")
    $sSWSw3 = IniRead($fIniConfig, $sSWName, "SwSw3", "")
    $sSWSw4 = IniRead($fIniConfig, $sSWName, "SwSw4", "")

    GUICtrlSetData($g6Input1, $sSWLoc1)
    GUICtrlSetData($g6Input2, $sSWLoc2)
    GUICtrlSetData($g6Input3, $sSWLoc3)
    GUICtrlSetData($g6Input4, $sSWLoc4)
    If $sSWSw1 <> "" Then
        GUICtrlSetData($g6Combo1, $sSWSw1, $sSWSw1)
    EndIf
    If $sSWSw2 <> "" Then
        GUICtrlSetData($g6Combo2, $sSWSw2, $sSWSw2)
    EndIf
    If $sSWSw3 <> "" Then
        GUICtrlSetData($g6Combo3, $sSWSw3, $sSWSw3)
    EndIf
    If $sSWSw4 <> "" Then
        GUICtrlSetData($g6Combo4, $sSWSw4, $sSWSw4)
    EndIf

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                $sExit = MsgBox(262148, "Attention", "Do you want to close this window without saving?")
                If $sExit = 6 Then ; If they want to exit without saving, do it. Otherwise, they will save & window will exit.
                    GUISetState(@SW_ENABLE, $Form2)
                    GUIDelete($g6Form)
                    ExitLoop
                EndIf
            Case $g6Button5
                $sSWLoc1 = GUICtrlRead($g6Input1)
                IniWrite($fIniConfig, $sSWName, "SwLoc1", $sSWLoc1)
                $sSWLoc2 = GUICtrlRead($g6Input2)
                IniWrite($fIniConfig, $sSWName, "SwLoc2", $sSWLoc2)
                $sSWLoc3 = GUICtrlRead($g6Input3)
                IniWrite($fIniConfig, $sSWName, "SwLoc3", $sSWLoc3)
                $sSWLoc4 = GUICtrlRead($g6Input4)
                IniWrite($fIniConfig, $sSWName, "SwLoc4", $sSWLoc4)
                $sSWSw1 = GUICtrlRead($g6Combo1)
                IniWrite($fIniConfig, $sSWName, "SwSw1", $sSWSw1)
                $sSWSw2 = GUICtrlRead($g6Combo2)
                IniWrite($fIniConfig, $sSWName, "SwSw2", $sSWSw2)
                $sSWSw3 = GUICtrlRead($g6Combo3)
                IniWrite($fIniConfig, $sSWName, "SwSw3", $sSWSw3)
                $sSWSw4 = GUICtrlRead($g6Combo4)
                IniWrite($fIniConfig, $sSWName, "SwSw4", $sSWSw4)
                GUISetState(@SW_ENABLE, $Form2)
                GUIDelete($g6Form)
                ExitLoop
            Case $g6Button1
                $sSWLoc = FileOpenDialog ("Please Select Pre-Install Software #1", @ScriptDir & "\Software", "Applications (*.exe; *.msi)")
                GUICtrlSetData($g6Input1, $sSWLoc)
            Case $g6Button2
                $sSWLoc = FileOpenDialog ("Please Select Pre-Install Software #1", @ScriptDir & "\Software", "Applications (*.exe; *.msi)")
                GUICtrlSetData($g6Input2, $sSWLoc)
            Case $g6Button3
                $sSWLoc = FileOpenDialog ("Please Select Pre-Install Software #1", @ScriptDir & "\Software", "Applications/Registry (*.exe; *.msi; *.reg; *.key)")
                GUICtrlSetData($g6Input3, $sSWLoc)
            Case $g6Button4
                $sSWLoc = FileOpenDialog ("Please Select Pre-Install Software #1", @ScriptDir & "\Software", "Applications/Registry (*.exe; *.msi; *.reg; *.key)")
                GUICtrlSetData($g6Input4, $sSWLoc)
            Case $g6Button6
                $sSWLoc = GUICtrlRead($g6Input1)
                $aStringSplit = StringSplit($sSWLoc, "\")
                $sSWLoc = $aStringSplit[$aStringSplit[0]]
                _GetInstallerType($sSWLoc, $g6Combo5, $g6Combo1, Default, $g6Button6)
            Case $g6Button7
                $sSWLoc = GUICtrlRead($g6Input2)
                $aStringSplit = StringSplit($sSWLoc, "\")
                $sSWLoc = $aStringSplit[$aStringSplit[0]]
                _GetInstallerType($sSWLoc, $g6Combo6, $g6Combo2, Default, $g6Button7)
            Case $g6Button8
                $sSWLoc = GUICtrlRead($g6Input3)
                $aStringSplit = StringSplit($sSWLoc, "\")
                $sSWLoc = $aStringSplit[$aStringSplit[0]]
                _GetInstallerType($sSWLoc, $g6Combo7, $g6Combo3, Default, $g6Button8)
            Case $g6Button9
                $sSWLoc = GUICtrlRead($g6Input4)
                $aStringSplit = StringSplit($sSWLoc, "\")
                $sSWLoc = $aStringSplit[$aStringSplit[0]]
                _GetInstallerType($sSWLoc, $g6Combo8, $g6Combo4, Default, $g6Button9)
            Case $g6Combo5
                _SetSwitchData($g6Combo5, $g6Combo1, Default)
            Case $g6Combo6
                _SetSwitchData($g6Combo6, $g6Combo2, Default)
            Case $g6Combo7
                _SetSwitchData($g6Combo7, $g6Combo3, Default)
            Case $g6Combo8
                _SetSwitchData($g6Combo8, $g6Combo4, Default)
            Case $g6Label13
                GUICtrlSetData($g6Input1, "")
                GUICtrlSetData($g6Combo5, "", "")
                GUICtrlSetData($g6Combo1, "", "")
                GUICtrlSetData($g6Combo5, $sAllInstallers, "")
                GUICtrlSetData($g6Combo1, $sAllSwitches, "")
            Case $g6Label14
                GUICtrlSetData($g6Input2, "")
                GUICtrlSetData($g6Combo6, "", "")
                GUICtrlSetData($g6Combo2, "", "")
                GUICtrlSetData($g6Combo6, $sAllInstallers, "")
                GUICtrlSetData($g6Combo2, $sAllSwitches, "")
            Case $g6Label15
                GUICtrlSetData($g6Input3, "")
                GUICtrlSetData($g6Combo7, "", "")
                GUICtrlSetData($g6Combo3, "", "")
                GUICtrlSetData($g6Combo7, $sAllInstallers, "")
                GUICtrlSetData($g6Combo3, $sAllSwitches, "")
            Case $g6Label16
                GUICtrlSetData($g6Input4, "")
                GUICtrlSetData($g6Combo8, "", "")
                GUICtrlSetData($g6Combo4, "", "")
                GUICtrlSetData($g6Combo8, $sAllInstallers, "")
                GUICtrlSetData($g6Combo4, $sAllSwitches, "")
        EndSwitch
    WEnd
EndFunc

Func _HelpTopics()
    $Form7 = GUICreate("Help", 633, 447)
    $Label1 = GUICtrlCreateLabel("", 8, 16, 612, 425)
    GUICtrlSetData(-1, "This program uses silent switches to install software without user interaction. " & _
    "To use this functionality, you can edit the Config.ini file to add software and their switches. Example: " & _
    @CRLF & @CRLF & "[7z1900-x64.exe] ; <--- This is the actual file name" & _
    @CRLF & "Description=YourDescripton" & @CRLF & "Switch=YourSwitcth" & @CRLF & "Category=YourCategory" & @CRLF & "etc... etc..." & _
    @CRLF & @CRLF & "Here are some common switches for various installers: (more included in this program's features)" & @CRLF & @CRLF & "/silent used for Inno Setup installers" & @CRLF & _
    "/verysilent used for Inno Setup installers" & @CRLF & "/S used for Nullsoft (aka NSIS) installers" & @CRLF & "/s used for Wise installers" & _
    @CRLF & "-s used for Ghost installers" & @CRLF & "-ms used for Mozilla installers" & @CRLF & "/quiet used for Microsoft installers" & @CRLF & _
    "/qb used for Microsoft installers" & @CRLF & "/qn used for  Microsoft installers" & @CRLF & "/passive used for Microsoft installers" & @CRLF & _
    "/Q used for Microsoft installers")
    GUISetState(@SW_SHOW)

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                GUIDelete($Form7)
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>_HelpTopics

Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    Local $tStruct = DllStructCreate($tagNMHDR, $lParam)
    Local $hWndFrom = DllStructGetData($tStruct, 1)
    Local $iCode = BitAND(DllStructGetData($tStruct, 3), 0xFFFFFFFF)
    If $iCode = $NM_DBLCLK Then
        $sSWDblClk = StringTrimRight(_GUICtrlListView_GetItemTextString($hWndFrom), 1)
        GUICtrlSendToDummy($cDummy)
    EndIf
EndFunc   ;==>_WM_NOTIFY

 

Link to comment
Share on other sites

  • abberration changed the title to Software Installer

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

×
×
  • Create New...