RickyTechyTech

Installing software from a share folder

9 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



@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.


When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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.


When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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
            $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 = $file
    Select
            Case StringRight($setfile, 3) == "msi"
                RunWait(@ComSpec & " /c " & 'msiexec.exe /i ' & '"' & $setfile & '"' & ' /qb', $filepath, @SW_HIDE)
            Case StringRight($setfile, 3) == "zip"
                Global $stringSPL = StringSplit($setfile, ".", $STR_NOCOUNT)
                _Zip_UnzipAll($filepath & "\" & $setfile, @DesktopDir & "\short\" & $stringSPL[0], 532)
            Case StringRight($setfile, 3) == "rar"
                Local $rarsplit = StringSplit($setfile, ".", $STR_NOCOUNT)
                RunWait(@ComSpec & " /c " & 'unrar e "' & $filepath & '\' & $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 "' & $filepath & '\' & $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', $filepath)
            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 " & '"' & $filepath & "\" & $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-", $filepath, @SW_HIDE )
                            $foundsomething = "y"
                        ElseIf StringInStr ( $IDString, "Delphi" ) Then
                            RunWait ( @ComSpec & " /c " & '"' & $setfile & '"' & " /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-", $filepath, @SW_HIDE )
                            $foundsomething = "y"
                        ElseIf StringInStr ($IDString, "Wise") Then
                            RunWait ( @ComSpec & " /c " & '"' & $setfile & '"' & " /s", $filepath, @SW_HIDE )
                        ElseIf StringInStr ($IDString, "Nullsoft") Then
                            RunWait ( @ComSpec & " /c " & '"' & $setfile & '"' & " /S", $filepath, @SW_HIDE )
                        ElseIf StringInStr ($IDString, "Installshield 2003") Then
                            ;ShellExecuteWait ( $setfile, "/s /v /qb", $filepath )
                            RunWait ( @ComSpec & ' /c "' & $setfile & ' /s /v"/qb"', $filepath, @SW_HIDE )
                        Else
                            RunWait ( @ComSpec & " /c " & '"' & $setfile & '"', $filepath, @SW_HIDE )
                        EndIf
        Case Else
            Sleep (100)
    EndSelect
EndFunc

 

script.jpg

scriptb.jpg

peid.exe

Zip.au3

Share this post


Link to post
Share on other sites

I love this it does what I want to do but after Ive done some tweaks but when I start the install process and its scans from peid.exe it doesnt install my software is there something i missed cause i get no errors on this.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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