Sign in to follow this  
Followers 0
joshiieeii

Automated Application Installer

10 posts in this topic

#1 ·  Posted (edited)

Ok guys, been working hard on this application to automate the installation of applications.

**Just a little disclaimer, I am an up and coming NEWB :) , and I am still learning, so excuse my code.

Heres the flow of the Install I am trying to acheive:

Sort the array based on multiple conditions. I have a way to create an array based on what is checked, but I am having a hard time wrapping my head around how to sort the checked boxes based on a couple conditions.

The conditions I am trying to sort by are in an ini file located below:

I am trying to sort the checked array that determines what gets installed when by if the Reboot is yes and then by Order. I am unsure on how to do this, I have been looking at the help file.

If anyone could point me in the right direction, it would be much appreciated, I am still learning about arrays and how to manipulate them. :">

Config.ini

CODE

[Groups]

group1 = Developer User

group2 = Architect User

group3 = Standard User

[VPN]

Location=C:\windows\notepad.exe

Type=unmanaged

Standard User=yes

Reboot = Yes

Order = 100

[iPASS Connect]

Location=C:\windows\notepad.exe

Type=managed

Standard User=yes

Reboot = No

Order = 1

[Visual Studio 2005]

Location=C:\windows\notepad.exe

Type=unmanaged

Operations=yes

Reboot = Yes

Order = 2

[PerForce]

Location=C:\windows\notepad.exe

Type=Managed

[MS Office 2003 Pro]

Location=C:\windows\notepad.exe

Type=Unmanaged

Standard User=yes

[Adobe Reader 7]

Location=C:\windows\notepad.exe

Type=managed

Standard USer=yes

[Java 1.4.2_05]

Location=C:\windows\notepad.exe

Type=Unmanaged

Standard User=yes

[Agile]

Location=C:\windows\notepad.exe

Type=Unmanaged

[Autodesk]

Location=C:\windows\notepad.exe

Type=Unmanaged

[Avaya]

Location=C:\windows\notepad.exe

Type=Unmanaged

Standard USer=yes

[.NET Framework 1.1]

Location=C:\windows\notepad.exe

Type=Unmanaged

Standard uSer=yes

[Copernic]

Location=C:\windows\notepad.exe

Type=Unmanaged

[Citrix]

Location=C:\windows\notepad.exe

Type=Unmanaged

[NV DVD]

Location=C:\windows\notepad.exe

Type=Unmanaged

Standard User=yes

[VNC 4.1.1]

Location=C:\windows\notepad.exe

Type=Unmanaged

[Visual Studio .NET 2003]

Location=C:\windows\notepad.exe

Type=Unmanaged

[Visio Viewer]

Location=C:\windows\notepad.exe

Type=Unmanaged

Standard User=yes

[sAP]

Location=C:\windows\notepad.exe

Type=Unmanaged

[Trend]

Location=C:\windows\notepad.exe

Type=Unmanaged

Standard User=yes

[Dell D620 Utilities]

Location=C:\windows\notepad.exe

Type=Utilities & Tweaks

[Dell D820 Utilities]

Location=C:\windows\notepad.exe

Type=Utilities & Tweaks

[Dell D800 Utilities]

Location=C:\windows\notepad.exe

Type=Utilities & Tweaks

[Tecra M5 Utilities]

Location=C:\windows\notepad.exe

Type=Utilities & Tweaks

[Tecra M3 Utilities]

Location=C:\windows\notepad.exe

Type=Utilities & Tweaks

[united Micro NBP Utilities]

Location=C:\windows\notepad.exe

Type=Utilities & Tweaks

[Visual-Slickedit]

Location=C:\windows\notepad.exe

Type=Unmanaged

[Acrobat 7 Professional]

Location=C:\windows\notepad.exe

Type=managed

[Acrobat 7 Standard]

Location=C:\windows\notepad.exe

Type=managed

[Adobe Dreamweaver]

Location=C:\windows\notepad.exe

Type=managed

[Adobe Aftereffects 7 Std]

Location=C:\windows\notepad.exe

Type=managed

[Adobe Aftereffects 7 Pro]

Location=C:\windows\notepad.exe

Type=managed

[Adobe Photoshop CS2]

Location=C:\windows\notepad.exe

Type=managed

[Adobe Illustrator CS2]

Location=C:\windows\notepad.exe

Type=managed

[Adobe Indesign CS2]

Location=C:\windows\notepad.exe

Type=managed

[Adobe Premier]

Location=C:\windows\notepad.exe

Type=managed

[Adobe GoLive CS2]

Location=C:\windows\notepad.exe

Type=managed

[Adobe Framemaker 7.2]

Location=C:\windows\notepad.exe

Type=managed

[Adobe Flash]

Location=C:\windows\notepad.exe

Type=managed

[Corel Paint Shop Pro]

Location=C:\windows\notepad.exe

Type=managed

[Autodesk Autocad LT 2006]

Location=C:\windows\notepad.exe

Type=managed

[Autodesk Inventor]

Location=C:\windows\notepad.exe

Type=managed

[MS Project 2003]

Location=C:\windows\notepad.exe

Type=managed

[MS Visio 2003 Pro]

Location=C:\windows\notepad.exe

Type=managed

[MS Visio 2003]

Location=C:\windows\notepad.exe

Type=managed

[slick Edit 8.0]

Location=C:\windows\notepad.exe

Type=managed

[MS Frontpage 2003]

Location=C:\windows\notepad.exe

Type=managed

Here is the actual script:

CODE

#include "GUIConstants.au3"

#include <Array.au3>

;#NoTrayIcon

if not Fileexists( "config.ini" ) then

MsgBox(0, "Config.ini Error!", "Config.ini not found!")

Exit

Endif

;==========================================================================

;Create and sort $masterarray, contains names of sections in ini file

;Create and sort $grouparray, contains names of sw groups

;==========================================================================

$groups = IniReadSection("config.ini","Groups")

if @error then

MsgBox(0, "Config.ini Error!", "[Groups] section not found! You must have a [Groups] section at the top of config.ini!")

Exit

Endif

$masterarray = IniReadSectionNames("config.ini")

;_ArrayDisplay ( $Masterarray, "masterarray" )

;_ArraySort($masterarray,0,2)

if $masterarray[1] <> "Groups" then

MsgBox(0, "Config.ini Error!", "[Groups] is not first! You must move [Groups] to the top of the config.ini file!")

Exit

Endif

;_ArrayDisplay ( $Masterarray, "masterarray" )

$groupcount = 0

Dim $grouparray[uBound($groups)]

do

$grouparray [$groupcount] = $groups [$groupcount] [1]

$groupcount = $groupcount + 1

until $groupcount = UBound ($groups)

;===========================================================================

;INI Check for errors

;===========================================================================

$groupcount=2

do

$val = IniRead("config.ini",$masterarray[$groupcount],"Location","UHOHNOTHINGHERE")

if $val = "UHOHNOTHINGHERE" then

MsgBox(0, "Config.ini Error!", "Location not found in config.ini: " & $masterarray[$groupcount] & Chr(13) & "All programs must have a location!")

Exit

Elseif not FileExists( $val ) then

MsgBox(0, "Config.ini Error!", "File for " & $masterarray[$groupcount] & " not found at" & $val)

Exit

Else

$groupcount = $groupcount + 1

Endif

Until $groupcount = UBound ( $masterarray )

$groupcount = 2

do

$val = IniRead("config.ini",$masterarray[$groupcount],"Type","UHOHNOTHINGHERE")

if $val = "UHOHNOTHINGHERE" then

MsgBox(0, "Config.ini Error!", "Type not found in config.ini: " & $masterarray[$groupcount] & Chr(13) & "All programs must have a type! (Managed, Unmanaged, or Utilities & Tweaks)")

Exit

Elseif StringLower($val) = "managed" or StringLower($val) = "unmanaged" or StringLower($val) = "Utilities & Tweaks" then

$groupcount = $groupcount + 1

Else

MsgBox(0, "Config.ini Error!", 'Type for: ' & $masterarray[$groupcount] & ' must be "Managed", "Unmanaged", or "Utilities & Tweaks"!')

Exit

Endif

Until $groupcount = UBound ( $masterarray )

;===========================================================================

;Create $checkgroupsarray for groups

;===========================================================================

Dim $checkgroupsarray [ubound($grouparray)] [ubound($masterarray)]

$mastercount = 2

$groupcount = 1

do

do

If StringLower(IniRead ("config.ini",$masterarray[$mastercount],$grouparray[$groupcount],"No")) = "yes" then

$checkgroupsarray[$groupcount][$mastercount] = 1

Endif

$groupcount = $groupcount + 1

until $groupcount = UBound ($grouparray)

$groupcount = 1

$mastercount = $mastercount + 1

until $mastercount = UBound ($masterarray)

;===========================================================================

;Create GUI

;===========================================================================

;Create Window

GUICreate("MYCOMPANYNAME - Software Loader", 920, 600)

GUICtrlCreateLabel("What software would you like to install?", 30, 10)

;Create Groups

GuiCtrlCreateGroup("License-Managed Applications", 5, 150, 300, 400)

GuiCtrlCreateGroup("Unmanaged Applications", 315, 150, 300, 400)

GuiCtrlCreateGroup("Utilities and Tweaks", 625, 150, 290, 400)

;Create Buttons

$cancelbutton = GUICtrlCreateButton("&Cancel", 430, 560, 70, 30)

$okbutton = GUICtrlCreateButton("&Install", 350, 560, 70, 30)

GUICtrlSetFont ($okbutton, 9 , 600,0,"MS Dialog Light")

$uncheckbutton = GUICtrlCreateButton("&Uncheck All", 510, 560, 70, 30)

$rebootcheck = GUICtrlCreateCheckbox ("Reboot after install?", 600, 560, 120, 20)

;==============================================

;Create Radio Button group and radio buttons

;==============================================

GuiCtrlCreateGroup("Software Profiles:", 20, 40, 170, 105)

$groupcount = 1

$groupypos = 60

$groupxpos = 30

Dim $groupradio[ubound($grouparray)]

$groupradio[0] = "hi"

do

$groupradio[$groupcount] = GUICtrlCreateRadio ($grouparray[$groupcount], $groupxpos, $groupypos, 140, 20)

$groupcount = $groupcount+1

$groupypos = $groupypos + 20

if $groupypos > 120 then

$groupypos = 60

$groupxpos = $groupxpos + 145

Endif

until $groupcount = Ubound($grouparray) or $groupcount = 25

GUICtrlCreateGroup ("",-99,-99,1,1)

;==============================================

;Create checkboxes

;==============================================

Dim $groupcheck[ubound($masterarray)]

$groupcheck[0] = "hi"

$groupcheck[1] = "hi"

;==========

;Managed

;==========

$groupcount = 2

$groupypos = 180

$groupxpos = 10

do

if IniRead ( "config.ini", $masterarray[$groupcount], "Type", "0" ) = "Managed" then

$groupcheck[$groupcount] = GUICtrlCreateCheckbox ($masterarray[$groupcount], $groupxpos, $groupypos, 140, 20)

$groupypos = $groupypos + 20

Endif

if $groupypos > 520 then

$groupypos = 180

$groupxpos = $groupxpos + 140

Endif

$groupcount = $groupcount + 1

until $groupcount = Ubound($masterarray)

;==========

;Unmanaged

;==========

$groupcount = 2

$groupypos = 180

$groupxpos = 320

do

if IniRead ( "config.ini", $masterarray[$groupcount], "Type", "0" ) = "Unmanaged" then

$groupcheck[$groupcount] = GUICtrlCreateCheckbox ($masterarray[$groupcount], $groupxpos, $groupypos, 140, 20)

$groupypos = $groupypos + 20

Endif

if $groupypos > 520 then

$groupypos = 180

$groupxpos = $groupxpos + 145

Endif

$groupcount = $groupcount + 1

until $groupcount = Ubound($masterarray)

;==========

;Utilities & Tweaks

;==========

$groupcount = 2

$groupypos = 180

$groupxpos = 630

do

if IniRead ( "config.ini", $masterarray[$groupcount], "Type", "0" ) = "Utilities & Tweaks" then

$groupcheck[$groupcount] = GUICtrlCreateCheckbox ($masterarray[$groupcount], $groupxpos, $groupypos, 135, 20)

$groupypos = $groupypos + 20

Endif

if $groupypos > 520 then

$groupypos = 180

$groupxpos = $groupxpos + 145

Endif

$groupcount = $groupcount + 1

until $groupcount = Ubound($masterarray)

;===========================================================================

;Poll GUI for events

;===========================================================================

; Show GUI, and wait for OK to be pressed

GUISetState()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

Exit

Case $msg = $cancelbutton

Exit

Case $msg = $uncheckbutton

call ( "UnCheckAll")

Case $msg = $okbutton

;====================================

;"Install" was pressed, create $checkedarray (contains a 1 for each checked box)

Dim $checkedarray[uBound ($masterarray)]

$groupcount = 2

do

$val = GUICtrlRead($groupcheck[$groupcount])

if $val = $GUI_CHECKED then

$checkedarray[$groupcount] = 1

else

$checkedarray[$groupcount] = 0

endif

$groupcount = $groupcount + 1

until $groupcount = UBound ($groupcheck)

$groupcount = 2

$checkedtotal = 0

do

$checkedtotal = $checkedtotal + $checkedarray[$groupcount]

$groupcount = $groupcount + 1

until $groupcount = UBound ($checkedarray)

$yval = 60 + (20 * $checkedtotal)

;_ArraySort ( $checkedarray, 1)

;_ArrayDisplay ($checkedarray, "")

;Complain if nothing is checked

if $checkedtotal = 0 then

MsgBox(0, "No entries selected!", "Nothing selected for installation!")

else

if GUICtrlRead($rebootcheck) = $GUI_CHECKED then

$reboot = 1

else

$reboot = 0

endif

ExitLoop

endif

;Back to the loop

;====================================

Case Else

$groupcount=1

do

if $msg = $groupradio[$groupcount] then

UncheckAll()

Checkgroup ($groupcount)

ExitLoop

else

$groupcount = $groupcount+1

Endif

until $groupcount = Ubound($groupradio) or $groupcount = 21

EndSelect

Wend

GuiDelete();get rid of GUI

;===========================================================================

;Create list window

;===========================================================================

;Create window, yval was calculated when install was pressed

GUICreate("Installing...", 200, $yval, 50 ,50 , $WS_EX_STATICEDGE, $WS_EX_TOPMOST)

;Create labels

$groupcount = 2

$yval = 10

Dim $labelarray[uBound($checkedarray)]

do

if $checkedarray[$groupcount] = 1 then

$labelarray[$groupcount] = GUICtrlCreateLabel($masterarray[$groupcount], 10, $yval, 290)

$yval = $yval + 20

endif

$groupcount = $groupcount + 1

until $groupcount = UBound($checkedarray)

;create reboot label if reboot was requested

if $reboot = 1 then

$rebootlabel = GUICtrlCreateLabel("-Reboot-", 10, $yval, 290)

endif

GUISetState()

;===========================================================================

;Do the installation

;===========================================================================

$groupcount = 2

do

if $checkedarray[$groupcount] = 1 then

GUICtrlSetFont ($labelarray[$groupcount], 9 , 600,0,"MS Dialog Light")

RunWait (IniRead ("config.ini",$masterarray[$groupcount],"Location","error"))

;Sleep(3000)

GUICtrlSetFont ($labelarray[$groupcount], 9 , 400,0,"MS Dialog Light")

endif

$groupcount = $groupcount + 1

until $groupcount = UBound ($masterarray)

;======================

;Reboot if requested

;======================

if $reboot = 1 then

GUICtrlSetFont ($rebootlabel, 9 , 600,0,"MS Dialog Light")

Sleep (5000)

Shutdown (6)

endif

GuiDelete()

Exit

;===========================================================================

;Poll GUI for events

;===========================================================================

; Show GUI, and wait for OK to be pressed

GUISetState()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

Exit

Case $msg = $cancelbutton

Exit

Case $msg = $uncheckbutton

UnCheckAll()

Case $msg = $okbutton

;====================================

;"Install" was pressed, create $checkedarray (contains a 1 for each checked box)

Dim $checkedarray[uBound ($masterarray)]

$groupcount = 2

do

$val = GUICtrlRead($groupcheck[$groupcount])

if $val = $GUI_CHECKED then

$checkedarray[$groupcount] = 1

else

$checkedarray[$groupcount] = 0

endif

$groupcount = $groupcount + 1

until $groupcount = UBound ($groupcheck)

$groupcount = 2

$checkedtotal = 0

do

$checkedtotal = $checkedtotal + $checkedarray[$groupcount]

$groupcount = $groupcount + 1

until $groupcount = UBound ($checkedarray)

$yval = 60 + (20 * $checkedtotal)

;Complain if nothing is checked

if $checkedtotal = 0 then

MsgBox(0, "No entries selected!", "Nothing selected for installation!")

else

if GUICtrlRead($rebootcheck) = $GUI_CHECKED then

$reboot = 1

else

$reboot = 0

endif

ExitLoop

endif

;Back to the loop

;====================================

Case Else

$groupcount=1

do

if $msg = $groupradio[$groupcount] then

UncheckAll()

Checkgroup ($groupcount)

ExitLoop

else

$groupcount = $groupcount+1

Endif

until $groupcount = Ubound($groupradio) or $groupcount = 21

EndSelect

Wend

GuiDelete();get rid of GUI

;===========================================================================

;Create list window

;===========================================================================

;Create window, yval was calculated when install was pressed

GUICreate("Installing...", 200, $yval, 50 ,50 , $WS_EX_STATICEDGE, $WS_EX_TOPMOST)

;Create labels

$groupcount = 2

$yval = 10

Dim $labelarray[uBound($checkedarray)]

do

if $checkedarray[$groupcount] = 1 then

$labelarray[$groupcount] = GUICtrlCreateLabel($masterarray[$groupcount], 10, $yval, 290)

$yval = $yval + 20

endif

$groupcount = $groupcount + 1

until $groupcount = UBound($checkedarray)

;create reboot label if reboot was requested

if $reboot = 1 then

$rebootlabel = GUICtrlCreateLabel("-Reboot-", 10, $yval, 290)

endif

GUISetState()

;===========================================================================

;Do the installation

;===========================================================================

$groupcount = 2

do

if $checkedarray[$groupcount] = 1 then

GUICtrlSetFont ($labelarray[$groupcount], 9 , 600,0,"MS Dialog Light")

RunWait (IniRead ("config.ini",$masterarray[$groupcount],"Location","error"))

;Sleep(3000)

GUICtrlSetFont ($labelarray[$groupcount], 9 , 400,0,"MS Dialog Light")

endif

$groupcount = $groupcount + 1

until $groupcount = UBound ($masterarray)

;======================

;Reboot if requested

;======================

if $reboot = 1 then

GUICtrlSetFont ($rebootlabel, 9 , 600,0,"MS Dialog Light")

Sleep (5000)

Shutdown (6)

endif

GuiDelete()

Exit

;===========================================================================

;Function - Check all boxes associated with group

;===========================================================================

Func Checkgroup($groupnumber)

$mastercount = 2

do

if $checkgroupsarray [$groupnumber] [$mastercount] = 1 then

GuiCtrlSetState($groupcheck[$mastercount], $GUI_CHECKED)

endif

$mastercount = $mastercount + 1

until $mastercount = UBound($masterarray)

EndFunc

;===========================================================================

;Function - Uncheck all boxes

;===========================================================================

Func Uncheckall()

$mastercount = 2

do

GuiCtrlSetState($groupcheck[$mastercount], $GUI_UNCHECKED)

$mastercount = $mastercount + 1

until $mastercount = UBound($groupcheck)

EndFunc

Edited by joshiieeii

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

*************************** Removed long code *******************

Can you edit your post and remove the code here:

http://www.autoitscript.com/forum/index.ph...t=0#entry188891

I am reusing this post and trying to get some more help regarding my automated application installer.

Thanks....btw...you are very good with AutoIt!!

Welcome... no prob

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

:D So I am thinking that I need to have a multi dimensional array.....

and that I need to first sort the checked applications by the order that they are associated with, and then the reboot value (reboot goes to the end of the line)...

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Ok, so I figured I would just put the sections in the ini file in the order I want them. and I am playing around with the _arraySwap function. So I am trying to read the ini and see if any of the sections contain a reboot = yes field, if they do, swap the checkedarray field with the one on the bottom.

Does anyone have any experience with the _arraySwap function?

I am placing this just before ";Complain if nothing is checked"

do
    if IniRead ( "config.ini", $checkedarray[$groupcount], "Reboot", "0" ) = "Yes" then
        _arrayswap ( $checkedarray [0], $checkedarray[$groupcount] )
        $groupcount = $groupcount + 1   
    EndIf
until $groupcount = Ubound($checkedarray)
Edited by joshiieeii

Share this post


Link to post
Share on other sites

This seems to work when I input numbers, but not when I try to use the variables.

Dim $endofline = 47
do
    if IniRead ( "config.ini", $masterarray[$groupcount], "Reboot", "0" ) = "Yes" then
        _arrayswap ( $masterarray [$groupcount], $masterarray[$endofline] )
    ;_ArrayDisplay ($checkedarray, "")
    ;_ArrayDisplay ($masterarray, "")
        $groupcount = $groupcount + 1   
        $endofline = $endofline - 1
    EndIf
until $groupcount = Ubound($masterarray)

Share this post


Link to post
Share on other sites

do you think you can do us all a favor and change your [ code] tags to [ codebox] tags.

Thx. page was taking forever to open so I hit stop o_O not really sure if this post is even guna go through.

Share this post


Link to post
Share on other sites

do you think you can do us all a favor and change your [ code] tags to [ codebox] tags.

Thx. page was taking forever to open so I hit stop o_O not really sure if this post is even guna go through.

Was not aware of the "codebox" tags, not in the options when you post. Changed....

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
Sign in to follow this  
Followers 0