Jump to content

Installing software from a share folder


Recommended Posts

So I have a a form with a script directory and the form has two tab sheets. The goal is to compile the script and the conf.ini file with a folder with the software in it. Im not sure if that it is possible but if there another route of doing this is also have this program connect to a share folder to a server on the network that will access by user credintials and say hey I need this program installed I click it and it connects to the share and installs it.

This is what I have at this moment.

#include <GUIConstants.au3>
#include <GuiListView.au3>
#include <Array.au3>
#include <File.au3>

 Global $inifile = @ScriptDir & "Config.ini"
;Global @ScriptDir = @ScriptDir

; Main GUI
$Form1 = GUICreate("Software Installer", 633, 451)

$Tab1 = GUICtrlCreateTab(16, 8, 601, 377)
$Tabsheet1 = GUICtrlCreateTabItem("Test Dept 1")
$ListView1 = GUICtrlCreateListView("Software|Description", 24, 40, 582, 334)
$MenuItem1 = GUICtrlCreateMenu("File")
$MenuItem2 = GUICtrlCreateMenuItem("Unselect All",$MenuItem1)
$MenuItem3 = GUICtrlCreateMenuItem("Exit", $MenuItem1)
$MenuItem4 = GUICtrlCreateMenu("Help")
$MenuItem5 = GUICtrlCreateMenuItem("Help Topics", $MenuItem4)
$MenuItem6 = GUICtrlCreateMenuItem("About", $MenuItem4)
_Populate()
GUisetstate(@sw_show)

While 1
    $nMsg = GUIGetMsg()
    Switch    $nMsg
        Case $gui_Event_Close
            Exit
        Case $Button1
            _InstallSelecetedSoftware()
        Case $MenuItem3
            Exit
        Case $MenuItem5
            _HelpTopics()
        Case $MenuItem6
            _AboutProject()
       EndSwitch
    WEnd
        Func _Populate()
            $OsArch = @OSArch
; Find all files in the Software folder and populate the tabs with the installers.
$f = FileFindFirstFile("Software/*.*")
Dim $array[1]
$i = 0
Do
$s = FileFindNextFile($f)
If Not @error Then
$array[$i] = $s
$i += 1
ReDim $array[$i + 1]
EndIf
Until @error
ReDim $array[$i]

Select
Case $OsArch = "X64"
For $i = 1 To UBound($array) Step 1
$category = IniRead($iniFile, $array[$i - 1], "Category", "6")
$desc = IniRead($iniFile, $array[$i - 1], "Desc", "")
$IniArch = IniRead($iniFile, $array[$i - 1], "Arch", "")
If $category = 1 And $IniArch > 32 Then
GUICtrlCreateListViewItem($array[$i - 1] & "|" & $desc, $ListView1)
ElseIf $category = 2 And $IniArch > 32 Then
GUICtrlCreateListViewItem($array[$i - 1] & "|" & $desc, $ListView2)
ElseIf $category = 3 And $IniArch > 32 Then
GUICtrlCreateListViewItem($array[$i - 1] & "|" & $desc, $ListView3)
ElseIf $category = 4 And $IniArch > 32 Then
GUICtrlCreateListViewItem($array[$i - 1] & "|" & $desc, $ListView4)
ElseIf $category = 5 And $IniArch > 32 Then
GUICtrlCreateListViewItem($array[$i - 1] & "|" & $desc, $ListView5)
ElseIf $category = 6 And $IniArch > 32 Then
GUICtrlCreateListViewItem($array[$i - 1] & "|" & $desc, $ListView6)
Else
GUICtrlCreateListViewItem($array[$i - 1] & "|" & $desc, $ListView7)
EndIf
Next
Case $OsArch = "X86"
For $i = 1 To UBound($array) Step 1
$category = IniRead($iniFile, $array[$i - 1], "Category", "6")
$desc = IniRead($iniFile, $array[$i - 1], "Desc", "")
$IniArch = IniRead($iniFile, $array[$i - 1], "Arch", "")
If $category = 1 And $IniArch <> 64 Then
GUICtrlCreateListViewItem($array[$i - 1] & "|" & $desc, $ListView1)
ElseIf $category = 2 And $IniArch <> 64 Then
GUICtrlCreateListViewItem($array[$i - 1] & "|" & $desc, $ListView2)
ElseIf $category = 3 And $IniArch <> 64 Then
GUICtrlCreateListViewItem($array[$i - 1] & "|" & $desc, $ListView3)
ElseIf $category = 4 And $IniArch <> 64 Then
GUICtrlCreateListViewItem($array[$i - 1] & "|" & $desc, $ListView4)
ElseIf $category = 5 And $IniArch <> 64 Then
GUICtrlCreateListViewItem($array[$i - 1] & "|" & $desc, $ListView5)
ElseIf $category = 6 And $IniArch <> 64 Then
GUICtrlCreateListViewItem($array[$i - 1] & "|" & $desc, $ListView6)
Else
GUICtrlCreateListViewItem($array[$i - 1] & "|" & $desc, $ListView7)
EndIf
Next
EndSelect
EndFunc ;==>_Populate

 

Edited by JLogan3o13
Link to comment
Share on other sites

  • Moderators

@RickyTechyTech are you providing this script as an Example of how it can be done, or are you asking for assistance? Your post is a bit vague...

Also, in the future please put your code between code tags <>. It makes it much more readable.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

My apologies it's not a example if anyone wants use it go ahead. I added the script in here to see if I can get any assistants. The image below is what I had setup previously. So In each tab will have different types of software. Normally you can put it in a folder with a ini file and install it. now since im not able to compile or build this with the software in it. I would be useless. So what I like to do is instead of making a folder with all the software I want to do instead is when I click on a tab of the departments and I see the software I want to click it and install it from the the location. So meaning our software is located on a share folder on our server.

 

Capture.PNG

Link to comment
Share on other sites

  • Moderators

Then I will move this thread to the appropriate forum, as the Examples forum you posted in clearly states: 

Do not post general support questions here, instead use the AutoIt Help and Support forums.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

You could pack up all your install files into your compiled autoit program with

#AutoIt3Wrapper_Res_File_Add=Path, to, your, programs

then you can use FileInstall to extract the desired install software and install it.

It will make your compiled exe bigger because all of those install software will be packed up into your exe but it eliminates a folder with all of the install software.

Link to comment
Share on other sites

I have a script that I have written a while ago which does this.  Technically, it only "shellexecute" opens documents, but I can re-write it and incorporate another silent install script I have.  BTW, the only issue that I ran into when trying to access files from a file share is the making sure the user context under which you launch the script has permission to access the file share.  For example, I have to launch my script under the "Default" execution level, since trying to launch it under the "Run as administrator" was preventing me from accessing the file share.  However, if the account you are running the script as is a member of the local administrator group, no problems at all

Link to comment
Share on other sites

Ok.  So here it is.  Note that if you want to use it as is, you will need to put the attached "zip.au3" udf in your includes folder and you will need to modify the script at line 186 with the "fileinstall" function and put in the path for the second attachment, peid.exe.  Note that the code from line 186 down was inspired by a posting I found a while back that contains an autoit script meant to return silent install switches from scanned executables (http://www.msfn.org/board/topic/17940-universal-silent-switch-finder-01/)  He gets all the credit for that.

; *** Start added by AutoIt3Wrapper ***
#include <FileConstants.au3>
#include <ListBoxConstants.au3>
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
; *** End added by AutoIt3Wrapper ***
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Add_Constants=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.15.0 (Beta)
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiComboBox.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <File.au3>
#include <Zip.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#Region ### START Koda GUI section ### Form=c:\users\whiggs\onedrive\always script\form\openjv3.kxf
$Form1 = GUICreate("Install Launcher", 500, 593, 192, 124, BitOR($GUI_SS_DEFAULT_GUI,$DS_SETFOREGROUND), BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
$MenuItem1 = GUICtrlCreateMenu("Add")
$MenuItem2 = GUICtrlCreateMenuItem("Folder", $MenuItem1)
$Label1 = GUICtrlCreateLabel("Pick your poison", 176, 16, 147, 29)
GUICtrlSetFont(-1, 15, 400, 0, "MS Sans Serif")
$dumm = GUICtrlCreateDummy()
$Combo1 = GUICtrlCreateCombo("", 40, 56, 409, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_SIMPLE,$CBS_SORT,$WS_HSCROLL))
GUICtrlSetTip(-1, "Select the path you wish to view....")
$List1 = GUICtrlCreateList("", 24, 96, 449, 422, BitOR($LBS_NOTIFY, $LBS_MULTIPLESEL, $LBS_HASSTRINGS, $WS_VSCROLL, $WS_BORDER))
$Button1 = GUICtrlCreateButton("Run", 48, 536, 89, 33, $BS_NOTIFY)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetCursor (-1, 0)
$Button2 = GUICtrlCreateButton("Exit", 360, 536, 81, 33, $BS_NOTIFY)
GUICtrlSetCursor (-1, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
If Not FileExists ( @ScriptDir & "\settings.ini" ) Then
addPath()
Else
    $array2 = IniReadSection ( @ScriptDir & "\settings.ini", "settings" )
        Local $store2[$array2[0][0]]
        $here2 = 0
        For $i = 1 To $array2[0][0] Step 1
            GUICtrlSetData ( $Combo1, $array2[$i][1] )
        ;   $here2 += 1
        Next
        ;GUICtrlSetData ( $Combo1, $store2 )
EndIf
GUIRegisterMsg($WM_COMMAND, "doubleClick")
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $MenuItem2
            addPath()

        Case $Combo1
            _GUICtrlListBox_ResetContent ( $List1 )
            $use = GUICtrlRead ( $Combo1 )
            If Not FileExists ( $use ) Then
                #Region --- CodeWizard generated code Start ---

;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=None, Miscellaneous=Top-most attribute
MsgBox($MB_OK + 262144,"invalid path","the path you selected does not exist or is inaccessible on local device/using current user.")
#EndRegion --- CodeWizard generated code End ---
                Else


            GUICtrlSetState ( $Button1, 128 )
            GUICtrlSetStyle ($List1, BitOR($LBS_NOTIFY, $LBS_MULTIPLESEL, $LBS_HASSTRINGS, $WS_VSCROLL, $WS_BORDER))
            $thelist = _FileListToArrayRec ( $use, "*", Default, Default, $FLTAR_SORT, Default )
            For $i = 1 To $thelist[0] Step 1
                GUICtrlSetData ( $List1, $thelist[$i] )
            Next
                EndIf

        Case $List1
            $listselect = _GUICtrlListBox_GetSelItemsText ( $List1 )
            If $listselect[0] > 0 Then
                GUICtrlSetState ( $Button1, 64 )
            Else
                GUICtrlSetState ( $Button1, 128 )
            EndIf

        Case $Button1
            $listsel = _GUICtrlListBox_GetSelItemsText ( $List1 )
            For $f = 1 To $listsel[0] Step 1
                apps ($listsel[$f])
            Next

        Case $Button2
            Exit
    EndSwitch
WEnd

Func addPath ()
    If Not FileExists ( @ScriptDir & "\settings.ini" ) Then
    #Region --- CodeWizard generated code Start ---


;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=Info
MsgBox($MB_OK + $MB_ICONASTERISK,"Select paths","You need to select some file share paths so program knows where to look")
#EndRegion --- CodeWizard generated code End ---
        $hold = 0
    Else
        $hold = IniReadSection ( @ScriptDir & "\settings.ini", "settings" )
    EndIf

    Do
        $init = FileSelectFolder ( "Select path to add", "" )
        If $init <> "" Then
            If IsArray ( $hold ) Then
                $hold[0][0] += 1
                IniWrite ( @ScriptDir & "\settings.ini", "settings", "path " & $hold[0][0], $init )
            Else
                $hold += 1
                IniWrite ( @ScriptDir & "\settings.ini", "settings", "path " & $hold, $init )
            EndIf

        EndIf
        #Region --- CodeWizard generated code Start ---

;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes and No, Icon=None
If Not IsDeclared("continue") Then Local $continue
$continue = MsgBox($MB_YESNO,"More?","Are there any more you would like to enter?")
        Until $continue = $IDNO
        $array = IniReadSection ( @ScriptDir & "\settings.ini", "settings" )
        Local $store[$array[0][0]]
        $here = 0
        For $i = 1 To $array[0][0] Step 1
            GUICtrlSetData ( $Combo1, $array[$i][1] )
            ;$here += 1
        Next
        ;GUICtrlSetData ( $Combo1, $store )
    EndFunc

#EndRegion --- CodeWizard generated code End ---
Func doubleClick($hWnd, $Msg, $wParam, $lParam)
    $nNotifyCode = BitShift($wParam, 16)
    $nID = BitAND($wParam, 0x0000FFFF)
    $hCtrl = $lParam
    Select
        Case $nID = $List1
            Switch $nNotifyCode
                Case $LBN_DBLCLK
                    $one = GUICtrlRead($List1)
                    If StringRight ( $one, 4 ) == ".exe" Or StringRight ( $one, 4 ) == ".msi" Then
                        apps ($one)
                    EndIf
            EndSwitch
    EndSelect
EndFunc

Func apps ($file)
    $filepath = GUICtrlRead ( $Combo1 )
    $setfile = $filepath & "\" & $file
    Select
            Case StringRight($setfile, 3) == "msi"
                RunWait(@ComSpec & " /c " & 'msiexec.exe /i ' & '"' & $setfile & '"' & ' /qb', "", @SW_HIDE)
            Case StringRight($setfile, 3) == "zip"
                Global $stringSPL = StringSplit($setfile, ".", $STR_NOCOUNT)
                _Zip_UnzipAll($setfile, @DesktopDir & "\short\" & $stringSPL[0], 532)
            Case StringRight($setfile, 3) == "rar"
                Local $rarsplit = StringSplit($setfile, ".", $STR_NOCOUNT)
                RunWait(@ComSpec & " /c " & 'unrar e "' & $setfile & '" "' & @DesktopDir & '\short\' & $rarsplit[0] & '\"', "C:\Program Files\WinRAR")
            Case StringRight($setfile, 2) == "7z"
                Local $7split = StringSplit($setfile, ".", $STR_NOCOUNT)
                RunWait(@ComSpec & " /c " & '7z x "' & $setfile & '" -o"' & @DesktopDir & '\short\' & $7split[0] & '\"', "C:\Program Files\7-Zip")
            Case StringRight($setfile, 11) == "application"
                ShellExecuteWait($setfile, "", $filepath)
            Case StringRight($setfile, 3) == "msu"
                RunWait(@ComSpec & " /c " & 'wusa.exe ' & $setfile & ' /quiet /norestart', "" )
            Case StringRight($setfile, 3) == "exe"
                        If Not FileExists (@ScriptDir & "\peid.exe") Then
                            FileInstall("C:\Users\whiggs\OneDrive\always script\mdt\PEiD.exe", @ScriptDir & "\peid.exe")
                        EndIf
                        Run ("peid.exe -hard " & '"' & $setfile & '"', @ScriptDir, @SW_HIDE )
                        WinWait ( "PEiD v0.95" )
                        $IDString= ControlGetText("PEiD v0.95", "", "[CLASS:Edit; INSTANCE:2]")
                        Do
                            Sleep (100)
                            $IDString= ControlGetText("PEiD v0.95", "", "Edit2")
                        Until ($IDString <>"Scanning...") And ($IDString <> "" )
                        WinClose ("PEiD v0.95")
                        $foundsomething = "n"
                        If StringInStr ($IDString, "Inno Setup") Then
                            RunWait ( @ComSpec & " /c " & '"' & $setfile & '"' & " /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-", "", @SW_HIDE )
                            $foundsomething = "y"
                        ElseIf StringInStr ( $IDString, "Delphi" ) Then
                            RunWait ( @ComSpec & " /c " & '"' & $setfile & '"' & " /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-", "", @SW_HIDE )
                            $foundsomething = "y"
                        ElseIf StringInStr ($IDString, "Wise") Then
                            RunWait ( @ComSpec & " /c " & '"' & $setfile & '"' & " /s", "", @SW_HIDE )
                        ElseIf StringInStr ($IDString, "Nullsoft") Then
                            RunWait ( @ComSpec & " /c " & '"' & $setfile & '"' & " /S", "", @SW_HIDE )
                        ElseIf StringInStr ($IDString, "Installshield 2003") Then
                            ;ShellExecuteWait ( $setfile, "/s /v /qb", $filepath )
                            RunWait ( @ComSpec & ' /c "' & $setfile & ' /s /v"/qb"', "", @SW_HIDE )
                        Else
                            RunWait ( @ComSpec & " /c " & '"' & $setfile & '"', "", @SW_HIDE )
                        EndIf
        Case Else
            Sleep (100)
    EndSelect
EndFunc

 

script.jpg

scriptb.jpg

peid.exe

Zip.au3

Edited by MattHiggs
Link to comment
Share on other sites

  • 1 month later...

Hello Mattiggs,

    I just found your code and tested it; it works like a charm except that when I change folders according to my settings.ini, it does not clear the previously listed files...instead, the list gets populated everytime I open a new folder.

For example, when I open the fist folder "Audio", I get the following content:

-aimp_3.00.815_beta_1.exe

When I open the second folder "Autocad", I get the following:

-aimp_3.00.815_beta_1.exe  <--(This shouldn't be here)
-dwgseepro2017.exe
-PLTViewerSetup.exe
-TotalCADConverter(1).exe
-View Companion.exe

When I open the second folder "Autocad", I get the following:

-aimp_3.00.815_beta_1.exe  <--(This shouldn't be here)
-dwgseepro2017.exe
-PLTViewerSetup.exe
-TotalCADConverter(1).exe
-View Companion.exe

And so on and so forth.

My settings.ini is as follows:

[settings]
path 1=\\serverproy\soft\__install\Audio
path 2=\\serverproy\soft\__install\Autocad
path 3=\\serverproy\soft\__install\Correo
path 4=\\serverproy\soft\__install\Diseño
path 5=\\serverproy\soft\__install\Internet
path 6=\\serverproy\soft\__install\PDF
path 7=\\serverproy\soft\__install\Video
path 8=\\serverproy\soft\__install\Windows

 

Any help will be greately appreciated.

Thanks before hand.

Link to comment
Share on other sites

On 10/17/2016 at 10:53 AM, Charlie_Tango said:

Hello Mattiggs,

    I just found your code and tested it; it works like a charm except that when I change folders according to my settings.ini, it does not clear the previously listed files...instead, the list gets populated everytime I open a new folder.

For example, when I open the fist folder "Audio", I get the following content:

-aimp_3.00.815_beta_1.exe

When I open the second folder "Autocad", I get the following:

-aimp_3.00.815_beta_1.exe  <--(This shouldn't be here)
-dwgseepro2017.exe
-PLTViewerSetup.exe
-TotalCADConverter(1).exe
-View Companion.exe

When I open the second folder "Autocad", I get the following:

-aimp_3.00.815_beta_1.exe  <--(This shouldn't be here)
-dwgseepro2017.exe
-PLTViewerSetup.exe
-TotalCADConverter(1).exe
-View Companion.exe

And so on and so forth.

My settings.ini is as follows:

[settings]
path 1=\\serverproy\soft\__install\Audio
path 2=\\serverproy\soft\__install\Autocad
path 3=\\serverproy\soft\__install\Correo
path 4=\\serverproy\soft\__install\Diseño
path 5=\\serverproy\soft\__install\Internet
path 6=\\serverproy\soft\__install\PDF
path 7=\\serverproy\soft\__install\Video
path 8=\\serverproy\soft\__install\Windows

 

Any help will be greately appreciated.

Thanks before hand.

Hey all.  Sorry for the delay in getting back to you.  There is a really simple solution to this issue, and I'm sorry for taking so long to supply it to you.  I have edited my original post's code with the updated, working code.  

Link to comment
Share on other sites

On 9/15/2016 at 6:27 PM, RickyTechyTech said:

Ok so I got it to install that was a user error <<<<<<<<  but how would i tell the setting.ini file to connect to a share folder on a network server i can add it without no problems and sees the folder with the software but it wont install could it be a credential issue or permission level

I'm sorry, I am not sure I understand what your issue is.  So you are able to see the folder and its contents in the GUI, but you are unable to launch the installer?  If that is the case I think I know what your issue is.  I will update the code, just give me one second.

Link to comment
Share on other sites

So the issue that you were having installing from the network shares was actually due to a issue I should have foreseen, and I apologize.  It is not installing because I set the Working directory parameter of the "RunWait" function which calls the installer to the path that is read from the Combo control.  Unfortunately, windows is unable to set the working directory to a file share, so it defaults to a local directory, and then cannot find the executable to execute as a result.  To combat this, I just included the full path of the executable in the RunWait Function and eliminated the dependency on the working directory.  The below code and attached files should now work for both files on file share and files located on local machine.

; *** Start added by AutoIt3Wrapper ***
#include <FileConstants.au3>
#include <ListBoxConstants.au3>
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
; *** End added by AutoIt3Wrapper ***
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Add_Constants=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.15.0 (Beta)
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiComboBox.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <File.au3>
#include <Zip.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#Region ### START Koda GUI section ### Form=c:\users\whiggs\onedrive\always script\form\openjv3.kxf
$Form1 = GUICreate("Install Launcher", 500, 593, 192, 124, BitOR($GUI_SS_DEFAULT_GUI,$DS_SETFOREGROUND), BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
$MenuItem1 = GUICtrlCreateMenu("Add")
$MenuItem2 = GUICtrlCreateMenuItem("Folder", $MenuItem1)
$Label1 = GUICtrlCreateLabel("Pick your poison", 176, 16, 147, 29)
GUICtrlSetFont(-1, 15, 400, 0, "MS Sans Serif")
$dumm = GUICtrlCreateDummy()
$Combo1 = GUICtrlCreateCombo("", 40, 56, 409, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_SIMPLE,$CBS_SORT,$WS_HSCROLL))
GUICtrlSetTip(-1, "Select the path you wish to view....")
$List1 = GUICtrlCreateList("", 24, 96, 449, 422, BitOR($LBS_NOTIFY, $LBS_MULTIPLESEL, $LBS_HASSTRINGS, $WS_VSCROLL, $WS_BORDER))
$Button1 = GUICtrlCreateButton("Run", 48, 536, 89, 33, $BS_NOTIFY)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetCursor (-1, 0)
$Button2 = GUICtrlCreateButton("Exit", 360, 536, 81, 33, $BS_NOTIFY)
GUICtrlSetCursor (-1, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
If Not FileExists ( @ScriptDir & "\settings.ini" ) Then
addPath()
Else
    $array2 = IniReadSection ( @ScriptDir & "\settings.ini", "settings" )
        Local $store2[$array2[0][0]]
        $here2 = 0
        For $i = 1 To $array2[0][0] Step 1
            GUICtrlSetData ( $Combo1, $array2[$i][1] )
        ;   $here2 += 1
        Next
        ;GUICtrlSetData ( $Combo1, $store2 )
EndIf
GUIRegisterMsg($WM_COMMAND, "doubleClick")
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $MenuItem2
            addPath()

        Case $Combo1
            _GUICtrlListBox_ResetContent ( $List1 )
            $use = GUICtrlRead ( $Combo1 )
            If Not FileExists ( $use ) Then
                #Region --- CodeWizard generated code Start ---

;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=None, Miscellaneous=Top-most attribute
MsgBox($MB_OK + 262144,"invalid path","the path you selected does not exist or is inaccessible on local device/using current user.")
#EndRegion --- CodeWizard generated code End ---
                Else


            GUICtrlSetState ( $Button1, 128 )
            GUICtrlSetStyle ($List1, BitOR($LBS_NOTIFY, $LBS_MULTIPLESEL, $LBS_HASSTRINGS, $WS_VSCROLL, $WS_BORDER))
            $thelist = _FileListToArrayRec ( $use, "*", Default, Default, $FLTAR_SORT, Default )
            For $i = 1 To $thelist[0] Step 1
                GUICtrlSetData ( $List1, $thelist[$i] )
            Next
                EndIf

        Case $List1
            $listselect = _GUICtrlListBox_GetSelItemsText ( $List1 )
            If $listselect[0] > 0 Then
                GUICtrlSetState ( $Button1, 64 )
            Else
                GUICtrlSetState ( $Button1, 128 )
            EndIf

        Case $Button1
            $listsel = _GUICtrlListBox_GetSelItemsText ( $List1 )
            For $f = 1 To $listsel[0] Step 1
                apps ($listsel[$f])
            Next

        Case $Button2
            Exit
    EndSwitch
WEnd

Func addPath ()
    If Not FileExists ( @ScriptDir & "\settings.ini" ) Then
    #Region --- CodeWizard generated code Start ---


;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=Info
MsgBox($MB_OK + $MB_ICONASTERISK,"Select paths","You need to select some file share paths so program knows where to look")
#EndRegion --- CodeWizard generated code End ---
        $hold = 0
    Else
        $hold = IniReadSection ( @ScriptDir & "\settings.ini", "settings" )
    EndIf

    Do
        $init = FileSelectFolder ( "Select path to add", "" )
        If $init <> "" Then
            If IsArray ( $hold ) Then
                $hold[0][0] += 1
                IniWrite ( @ScriptDir & "\settings.ini", "settings", "path " & $hold[0][0], $init )
            Else
                $hold += 1
                IniWrite ( @ScriptDir & "\settings.ini", "settings", "path " & $hold, $init )
            EndIf

        EndIf
        #Region --- CodeWizard generated code Start ---

;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes and No, Icon=None
If Not IsDeclared("continue") Then Local $continue
$continue = MsgBox($MB_YESNO,"More?","Are there any more you would like to enter?")
        Until $continue = $IDNO
        $array = IniReadSection ( @ScriptDir & "\settings.ini", "settings" )
        Local $store[$array[0][0]]
        $here = 0
        For $i = 1 To $array[0][0] Step 1
            GUICtrlSetData ( $Combo1, $array[$i][1] )
            ;$here += 1
        Next
        ;GUICtrlSetData ( $Combo1, $store )
    EndFunc

#EndRegion --- CodeWizard generated code End ---
Func doubleClick($hWnd, $Msg, $wParam, $lParam)
    $nNotifyCode = BitShift($wParam, 16)
    $nID = BitAND($wParam, 0x0000FFFF)
    $hCtrl = $lParam
    Select
        Case $nID = $List1
            Switch $nNotifyCode
                Case $LBN_DBLCLK
                    $one = GUICtrlRead($List1)
                    If StringRight ( $one, 4 ) == ".exe" Or StringRight ( $one, 4 ) == ".msi" Then
                        apps ($one)
                    EndIf
            EndSwitch
    EndSelect
EndFunc

Func apps ($file)
    $filepath = GUICtrlRead ( $Combo1 )
    $setfile = $filepath & "\" & $file
    Select
            Case StringRight($setfile, 3) == "msi"
                RunWait(@ComSpec & " /c " & 'msiexec.exe /i ' & '"' & $setfile & '"' & ' /qb', "", @SW_HIDE)
            Case StringRight($setfile, 3) == "zip"
                Global $stringSPL = StringSplit($setfile, ".", $STR_NOCOUNT)
                _Zip_UnzipAll($setfile, @DesktopDir & "\short\" & $stringSPL[0], 532)
            Case StringRight($setfile, 3) == "rar"
                Local $rarsplit = StringSplit($setfile, ".", $STR_NOCOUNT)
                RunWait(@ComSpec & " /c " & 'unrar e "' & $setfile & '" "' & @DesktopDir & '\short\' & $rarsplit[0] & '\"', "C:\Program Files\WinRAR")
            Case StringRight($setfile, 2) == "7z"
                Local $7split = StringSplit($setfile, ".", $STR_NOCOUNT)
                RunWait(@ComSpec & " /c " & '7z x "' & $setfile & '" -o"' & @DesktopDir & '\short\' & $7split[0] & '\"', "C:\Program Files\7-Zip")
            Case StringRight($setfile, 11) == "application"
                ShellExecuteWait($setfile, "", $filepath)
            Case StringRight($setfile, 3) == "msu"
                RunWait(@ComSpec & " /c " & 'wusa.exe ' & $setfile & ' /quiet /norestart', "" )
            Case StringRight($setfile, 3) == "exe"
                        If Not FileExists (@ScriptDir & "\peid.exe") Then
                            FileInstall("C:\Users\whiggs\OneDrive\always script\mdt\PEiD.exe", @ScriptDir & "\peid.exe")
                        EndIf
                        Run ("peid.exe -hard " & '"' & $setfile & '"', @ScriptDir, @SW_HIDE )
                        WinWait ( "PEiD v0.95" )
                        $IDString= ControlGetText("PEiD v0.95", "", "[CLASS:Edit; INSTANCE:2]")
                        Do
                            Sleep (100)
                            $IDString= ControlGetText("PEiD v0.95", "", "Edit2")
                        Until ($IDString <>"Scanning...") And ($IDString <> "" )
                        WinClose ("PEiD v0.95")
                        $foundsomething = "n"
                        If StringInStr ($IDString, "Inno Setup") Then
                            RunWait ( @ComSpec & " /c " & '"' & $setfile & '"' & " /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-", "", @SW_HIDE )
                            $foundsomething = "y"
                        ElseIf StringInStr ( $IDString, "Delphi" ) Then
                            RunWait ( @ComSpec & " /c " & '"' & $setfile & '"' & " /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-", "", @SW_HIDE )
                            $foundsomething = "y"
                        ElseIf StringInStr ($IDString, "Wise") Then
                            RunWait ( @ComSpec & " /c " & '"' & $setfile & '"' & " /s", "", @SW_HIDE )
                        ElseIf StringInStr ($IDString, "Nullsoft") Then
                            RunWait ( @ComSpec & " /c " & '"' & $setfile & '"' & " /S", "", @SW_HIDE )
                        ElseIf StringInStr ($IDString, "Installshield 2003") Then
                            ;ShellExecuteWait ( $setfile, "/s /v /qb", $filepath )
                            RunWait ( @ComSpec & ' /c "' & $setfile & ' /s /v"/qb"', "", @SW_HIDE )
                        Else
                            RunWait ( @ComSpec & " /c " & '"' & $setfile & '"', "", @SW_HIDE )
                        EndIf
        Case Else
            Sleep (100)
    EndSelect
EndFunc

 

peid.exe

Zip.au3

Link to comment
Share on other sites

Thanks MattHiggs!

    The code is working like a charm now! This will definetly save me tons of work so I really thank you! One last request, though: How can I select only one file at a time and not make multiple selections? And, is there a way to list only certain files? Like *.exe and *.msi only?

Thanks again for your help and effort!

Edited by Charlie_Tango
Link to comment
Share on other sites

4 hours ago, Charlie_Tango said:

Thanks MattHiggs!

    The code is working like a charm now! This will definetly save me tons of work so I really thank you! One last request, though: How can I select only one file at a time and not make multiple selections? And, is there a way to list only certain files? Like *.exe and *.msi only?

Thanks again for your help and effort!

Glad you found this useful.  The following code is edited to the specifications you mentioned in your last post.  But just so you know, I made the list so that you could select multiple files so that you could select multiple applications you want to install, and when  you click "run", it will perform the installation for those executable files back-to-back, which I thought would be more useful than just forcing the user to select one file at a time. You can also alternatively just double-click on one of the list items and that will launch it as well.  But here is the edited code, and let me know if this works for you:

; *** Start added by AutoIt3Wrapper ***
#include <FileConstants.au3>
#include <ListBoxConstants.au3>
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
; *** End added by AutoIt3Wrapper ***
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Add_Constants=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.15.0 (Beta)
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiComboBox.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <File.au3>
#include <Zip.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#Region ### START Koda GUI section ### Form=c:\users\whiggs\onedrive\always script\form\openjv3.kxf
$Form1 = GUICreate("Install Launcher", 500, 593, 192, 124, BitOR($GUI_SS_DEFAULT_GUI,$DS_SETFOREGROUND), BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
$MenuItem1 = GUICtrlCreateMenu("Add")
$MenuItem2 = GUICtrlCreateMenuItem("Folder", $MenuItem1)
$Label1 = GUICtrlCreateLabel("Pick your poison", 176, 16, 147, 29)
GUICtrlSetFont(-1, 15, 400, 0, "MS Sans Serif")
$dumm = GUICtrlCreateDummy()
$Combo1 = GUICtrlCreateCombo("", 40, 56, 409, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_SIMPLE,$CBS_SORT,$WS_HSCROLL))
GUICtrlSetTip(-1, "Select the path you wish to view....")
$List1 = GUICtrlCreateList("", 24, 96, 449, 422, BitOR($LBS_NOTIFY, $LBS_HASSTRINGS, $WS_VSCROLL, $WS_BORDER))
$Button1 = GUICtrlCreateButton("Run", 48, 536, 89, 33, $BS_NOTIFY)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetCursor (-1, 0)
$Button2 = GUICtrlCreateButton("Exit", 360, 536, 81, 33, $BS_NOTIFY)
GUICtrlSetCursor (-1, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
If Not FileExists ( @ScriptDir & "\settings.ini" ) Then
addPath()
Else
    $array2 = IniReadSection ( @ScriptDir & "\settings.ini", "settings" )
        Local $store2[$array2[0][0]]
        $here2 = 0
        For $i = 1 To $array2[0][0] Step 1
            GUICtrlSetData ( $Combo1, $array2[$i][1] )
        ;   $here2 += 1
        Next
        ;GUICtrlSetData ( $Combo1, $store2 )
EndIf
GUIRegisterMsg($WM_COMMAND, "doubleClick")
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $MenuItem2
            addPath()

        Case $Combo1
            _GUICtrlListBox_ResetContent ( $List1 )
            $use = GUICtrlRead ( $Combo1 )
            If Not FileExists ( $use ) Then
                #Region --- CodeWizard generated code Start ---

;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=None, Miscellaneous=Top-most attribute
MsgBox($MB_OK + 262144,"invalid path","the path you selected does not exist or is inaccessible on local device/using current user.")
#EndRegion --- CodeWizard generated code End ---
                Else


            GUICtrlSetState ( $Button1, 128 )
            GUICtrlSetStyle ($List1, BitOR($LBS_NOTIFY, $LBS_HASSTRINGS, $WS_VSCROLL, $WS_BORDER))
            $thelist = _FileListToArrayRec ( $use, "*", Default, Default, $FLTAR_SORT, Default )
            For $i = 1 To $thelist[0] Step 1
                If StringRight ( $thelist[$i], 3 ) == "exe" Or StringRight ( $thelist[$i], 3 ) == "msi" Then
                    GUICtrlSetData ( $List1, $thelist[$i] )
                Else
                    ContinueLoop
                EndIf
            Next
                EndIf

        Case $List1
            $listselect = _GUICtrlListBox_GetSelItemsText ( $List1 )
            If $listselect[0] > 0 Then
                GUICtrlSetState ( $Button1, 64 )
            Else
                GUICtrlSetState ( $Button1, 128 )
            EndIf

        Case $Button1
            $listsel = _GUICtrlListBox_GetSelItemsText ( $List1 )
            For $f = 1 To $listsel[0] Step 1
                apps ($listsel[$f])
            Next

        Case $Button2
            Exit
    EndSwitch
WEnd

Func addPath ()
    If Not FileExists ( @ScriptDir & "\settings.ini" ) Then
    #Region --- CodeWizard generated code Start ---


;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=Info
MsgBox($MB_OK + $MB_ICONASTERISK,"Select paths","You need to select some file share paths so program knows where to look")
#EndRegion --- CodeWizard generated code End ---
        $hold = 0
    Else
        $hold = IniReadSection ( @ScriptDir & "\settings.ini", "settings" )
    EndIf

    Do
        $init = FileSelectFolder ( "Select path to add", "" )
        If $init <> "" Then
            If IsArray ( $hold ) Then
                $hold[0][0] += 1
                IniWrite ( @ScriptDir & "\settings.ini", "settings", "path " & $hold[0][0], $init )
            Else
                $hold += 1
                IniWrite ( @ScriptDir & "\settings.ini", "settings", "path " & $hold, $init )
            EndIf

        EndIf
        #Region --- CodeWizard generated code Start ---

;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes and No, Icon=None
If Not IsDeclared("continue") Then Local $continue
$continue = MsgBox($MB_YESNO,"More?","Are there any more you would like to enter?")
        Until $continue = $IDNO
        $array = IniReadSection ( @ScriptDir & "\settings.ini", "settings" )
        Local $store[$array[0][0]]
        $here = 0
        For $i = 1 To $array[0][0] Step 1
            GUICtrlSetData ( $Combo1, $array[$i][1] )
            ;$here += 1
        Next
        ;GUICtrlSetData ( $Combo1, $store )
    EndFunc

#EndRegion --- CodeWizard generated code End ---
Func doubleClick($hWnd, $Msg, $wParam, $lParam)
    $nNotifyCode = BitShift($wParam, 16)
    $nID = BitAND($wParam, 0x0000FFFF)
    $hCtrl = $lParam
    Select
        Case $nID = $List1
            Switch $nNotifyCode
                Case $LBN_DBLCLK
                    $one = GUICtrlRead($List1)
                    If StringRight ( $one, 4 ) == ".exe" Or StringRight ( $one, 4 ) == ".msi" Or StringRight ( $one, 4 ) == ".zip" Or StringRight ( $one, 4 ) == ".rar" Or StringRight ( $one, 3 ) == ".7z" Then
                        apps ($one)
                    EndIf
            EndSwitch
    EndSelect
EndFunc

Func apps ($file)
    $filepath = GUICtrlRead ( $Combo1 )
    $setfile = $filepath & "\" & $file
    Select
            Case StringRight($setfile, 3) == "msi"
                RunWait(@ComSpec & " /c " & 'msiexec.exe /i ' & '"' & $setfile & '"' & ' /qb', "", @SW_HIDE)
            Case StringRight($setfile, 3) == "zip"
                Global $stringSPL = StringSplit($setfile, ".", $STR_NOCOUNT)
                _Zip_UnzipAll($setfile, @DesktopDir & "\short\" & $stringSPL[0], 532)
            Case StringRight($setfile, 3) == "rar"
                Local $rarsplit = StringSplit($setfile, ".", $STR_NOCOUNT)
                RunWait(@ComSpec & " /c " & 'unrar e "' & $setfile & '" "' & @DesktopDir & '\short\' & $rarsplit[0] & '\"', "C:\Program Files\WinRAR")
            Case StringRight($setfile, 2) == "7z"
                Local $7split = StringSplit($setfile, ".", $STR_NOCOUNT)
                RunWait(@ComSpec & " /c " & '7z x "' & $setfile & '" -o"' & @DesktopDir & '\short\' & $7split[0] & '\"', "C:\Program Files\7-Zip")
            Case StringRight($setfile, 11) == "application"
                ShellExecuteWait($setfile, "", $filepath)
            Case StringRight($setfile, 3) == "msu"
                RunWait(@ComSpec & " /c " & 'wusa.exe ' & $setfile & ' /quiet /norestart', "" )
            Case StringRight($setfile, 3) == "exe"
                        If Not FileExists (@ScriptDir & "\peid.exe") Then
                            FileInstall("C:\Users\whiggs\OneDrive\always script\mdt\PEiD.exe", @ScriptDir & "\peid.exe")
                        EndIf
                        Run ("peid.exe -hard " & '"' & $setfile & '"', @ScriptDir, @SW_HIDE )
                        WinWait ( "PEiD v0.95" )
                        $IDString= ControlGetText("PEiD v0.95", "", "[CLASS:Edit; INSTANCE:2]")
                        Do
                            Sleep (100)
                            $IDString= ControlGetText("PEiD v0.95", "", "Edit2")
                        Until ($IDString <>"Scanning...") And ($IDString <> "" )
                        WinClose ("PEiD v0.95")
                        $foundsomething = "n"
                        If StringInStr ($IDString, "Inno Setup") Then
                            RunWait ( @ComSpec & " /c " & '"' & $setfile & '"' & " /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-", "", @SW_HIDE )
                            $foundsomething = "y"
                        ElseIf StringInStr ( $IDString, "Delphi" ) Then
                            RunWait ( @ComSpec & " /c " & '"' & $setfile & '"' & " /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-", "", @SW_HIDE )
                            $foundsomething = "y"
                        ElseIf StringInStr ($IDString, "Wise") Then
                            RunWait ( @ComSpec & " /c " & '"' & $setfile & '"' & " /s", "", @SW_HIDE )
                        ElseIf StringInStr ($IDString, "Nullsoft") Then
                            RunWait ( @ComSpec & " /c " & '"' & $setfile & '"' & " /S", "", @SW_HIDE )
                        ElseIf StringInStr ($IDString, "Installshield 2003") Then
                            ;ShellExecuteWait ( $setfile, "/s /v /qb", $filepath )
                            RunWait ( @ComSpec & ' /c "' & $setfile & ' /s /v"/qb"', "", @SW_HIDE )
                        Else
                            RunWait ( @ComSpec & " /c " & '"' & $setfile & '"', "", @SW_HIDE )
                        EndIf
        Case Else
            Sleep (100)
    EndSelect
EndFunc

 

Edited by MattHiggs
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...