Kleiner Posted November 15, 2004 Share Posted November 15, 2004 Hello, this is my first post so please dont hurt me. And English isnt my native language so please dont hurt me even more Here is the problem. I want to use a GUI with ~15 checkboxes. For each Checkbox I select an autoit.script should be executed. Background: Since we dont have Active Directory and OUs yet, we use images for each computer. After restoring the image a view configurations have to be made to the pc. Depending on the usage of the pc, these configurations differ. Therefore I wrote some scripts, which automate each configuration/installation. As I dont want to sit in front of the pc waiting for each install to finish before proceeding with the next one, I would like to use this GUI where I select all my configurations that have to be made, click the Start Install and use the time to work on something else. Here is, what I created so fare. Only the interesting parts are missing GuiCreate ("DBC-Installation", 526, 428, (@DesktopWidth - 526) / 2, (@DesktopHeight - 428) / 2, 0x04CF0000) $CHECKBOX_1 = GUICtrlCreatecheckbox ("DBC-Zertifikat", 20, 10, 90, 40) $CHECKBOX_2 = GUICtrlCreatecheckbox ("Set ID", 20, 40, 90, 40) $BUTTON_1 = GUICtrlCreatebutton ("Start Installation", 400, 300, 100, 40) GuiSetState (@SW_SHOW) While 1 $MSG = GuiGetMsg () Select Case $MSG = $CHECKBOX_1 $dbc_zertifikat = ( '_installscript_dbc_zertifikat.exe' ) ;;; Case $MSG = $CHECKBOX_2 $set_id = ( '_installscript_setid.exe' ) ;;; Case $MSG = $BUTTON_1 Run ??????? ;;; EndSelect Wend Exit Greetings Kleiner Link to comment Share on other sites More sharing options...
SlimShady Posted November 15, 2004 Share Posted November 15, 2004 I used your script and added some things. I'm sure you have a digital list of computer names. Put every computer name on a new line and the ParseCompList will work perfect. Good luck. expandcollapse popup#include <GUIConstants.au3> GuiCreate ("DBC-Installation", 526, 428, (@DesktopWidth - 526) / 2, (@DesktopHeight - 428) / 2, 0x04CF0000) $CompList = ParseCompList(@ScriptDir & "\ComputerList.txt") If NOT IsArray($CompList) Then Exit Dim $Computers[15][2] $CHECKBOX_1 = GUICtrlCreatecheckbox ("DBC-Zertifikat", 20, 10, 90, 20) $CHECKBOX_2 = GUICtrlCreatecheckbox ("Set ID", 120, 10, 90, 20) For $c = 0 To 8 $comp = GUICtrlCreatecheckbox ($CompList[$c + 1], 20, ($c + 1) * 40 + 10, 150, 20) $Computers[$c][0] = $comp $Computers[$c][1] = $CompList[$c + 1] Next For $c = 9 To 14 $comp = GUICtrlCreatecheckbox ($CompList[$c + 1], 170, ($c - 8) * 40 + 10, 150, 20) $Computers[$c][0] = $comp $Computers[$c][1] = $CompList[$c + 1] Next $BUTTON_1 = GUICtrlCreatebutton ("Start Installation", 300, 300, 100, 25) GuiSetState (@SW_SHOW) While 1 $MSG = GuiGetMsg () Select Case $MSG = $GUI_EVENT_CLOSE GUIDelete() Exit Case $MSG = $CHECKBOX_1 $dbc_zertifikat = ( '_installscript_dbc_zertifikat.exe' ) ;;; Case $MSG = $CHECKBOX_2 $set_id = ( '_installscript_setid.exe' ) ;;; Case $MSG = $BUTTON_1 For $i = 0 To UBound($Computers) - 1 If GUIRead($Computers[$i][0]) = $GUI_CHECKED Then $Computername = $Computers[$i][1] ;RunWait("\\server\share\program.exe " & $Computername) EndIf Next ;;; EndSelect Wend Exit Func ParseCompList($Filename) Local $Err Local $FileSize Local $ReadFile Local $OpenFile $FileSize = FileGetSize($Filename) $OpenFile = FileOpen($Filename, 0) If NOT FileExists($Filename) Then $Err = "The computer list file could not be found!" ElseIf $OpenFile = -1 Then $Err = "The computer list file could not be opened!" EndIf If $Err <> "" Then MsgBox(16, "Error!", $Err) Return "" Else $ReadFile = FileRead($OpenFile, $FileSize) $ReadFile = StringStripCR($ReadFile) Return StringSplit($ReadFile, @LF) EndIf EndFunc Link to comment Share on other sites More sharing options...
Kleiner Posted November 15, 2004 Author Share Posted November 15, 2004 (edited) Hi SlimShady, thanks for your answer. Your script is a little bit "large" for my purpose. Normally only one computer has to be configured. And even if its two, then the configuration differs so I cant run it on more machines. I tried something like this Dim $arguments While 1 $MSG = GuiGetMsg () Select Case $MSG = -3 Exit Case $MSG = 1 ;;; Case $MSG = $CHECKBOX_1 $arguments = "_installscript_dbc_zertifikat.exe" ;;; Case $MSG = $CHECKBOX_2 $arguments = $arguments & "_installscript_filezilla.exe" ;;; Case $MSG = $BUTTON_1 msgbox(0,"", $arguments) opt("ExpandVarStrings",1) Run(@COMSPEC & " /c runme.bat $arguments") ;;; EndSelect Wend Exit where runme.bat is: %1 %2 Unfortunetaly it doesn't work Greetings Kleiner Edited November 15, 2004 by Kleiner Link to comment Share on other sites More sharing options...
sPeziFisH Posted November 15, 2004 Share Posted November 15, 2004 (edited) Your script is a little bit "large" for my purpose. ...it was clear that it has to be 'not large'... german Kleiner = peeweekleiner = lesser, smaller, tinier Edited November 15, 2004 by sPeziFisH Link to comment Share on other sites More sharing options...
Kleiner Posted November 15, 2004 Author Share Posted November 15, 2004 (edited) Reading a few other posts, I modified my script to get it more comfortable concerning the usage: While $msg <> -3 $msg = GuiGetMsg() Select case $msg = $button_1 $state1 = GuiRead($CHECKBOX_1) $state2 = GuiRead($CHECKBOX_2) if $state1 = 1 Then $arg1 = "_installscript_dbc_zertifikat.exe" Else $arg1 = "" EndIf If $state2 = 1 Then $arg2 = "_installscript_filezilla.exe" Else $arg2 = "" EndIf $arguments = $arg1 & $arg2 MsgBox(0, "The arguments are", $arguments) Runwait(@ComSpec & " /c runme.bat & $arguments") ;;; ;Case $MSG = $PIC_1 ;;; EndSelect Wend But still it doesn't work. (And I don't understand all lines I copied into my script. I think reading will help) Grettings Kleiner @sPeziFisH nice Edited November 15, 2004 by Kleiner Link to comment Share on other sites More sharing options...
SlimShady Posted November 15, 2004 Share Posted November 15, 2004 You were talking about Active Directory and 15 checkboxes. I assumed you had 15 computers. Anyways, I fixed your last code. While $msg <> -3 $msg = GuiGetMsg() Select case $msg = $button_1 $state1 = GuiRead($CHECKBOX_1) $state2 = GuiRead($CHECKBOX_2) if $state1 = 1 Then $arg1 = "_installscript_dbc_zertifikat.exe" Else $arg1 = "" EndIf If $state2 = 1 Then $arg2 = "_installscript_filezilla.exe" Else $arg2 = "" EndIf If $arg1 <> "" AND $arg2 <> "" Then $arguments = $arg1 & ' ' & $arg2 ElseIf $arg1 <> "" Then $arguments = $arg1 ElseIf $arg2 <> "" Then $arguments = $arg2 EndIf MsgBox(0, "The arguments are", $arguments) Run(@ComSpec & " runme.bat " & $arguments) ;;; ;Case $MSG = $PIC_1 ;;; EndSelect Wend Link to comment Share on other sites More sharing options...
Kleiner Posted November 15, 2004 Author Share Posted November 15, 2004 (edited) Thank you again for your help, but Run(@ComSpec & " runme.bat " & $arguments) won't start the batchfile I found a way without using the batchfile. I'm sure, this isn't proper code, but at least it's working. expandcollapse popupGuiCreate ("DBC-Installation", 526, 428, (@DesktopWidth - 526) / 2, (@DesktopHeight - 428) / 2, 0x04CF0000) $CHECKBOX_1 = GUICtrlCreatecheckbox ("DBC-Zertifikat", 20, 10, 90, 40) $CHECKBOX_2 = GUICtrlCreatecheckbox ("FileZilla", 20, 40, 90, 40) $BUTTON_1 = GUICtrlCreatebutton ("Start Installation", 400, 300, 100, 40) GuiSetState (@SW_SHOW) Dim $arguments $msg = 0 While $msg <> -3 $msg = GuiGetMsg() Select case $msg = $button_1 $state1 = GuiRead($CHECKBOX_1) $state2 = GuiRead($CHECKBOX_2) if $state1 = 1 Then $arg1 = "_installscript_dbc_zertifikat.exe" Else $arg1 = "empty.exe" EndIf If $state2 = 1 Then $arg2 = "_installscript_filezilla.exe" Else $arg2 = "empty.exe" EndIf Runwait($arg1) Runwait($arg2) EndSelect Wend Exit If you have any other suggestions to make it more comfortable (no "empty.exe script"), less code... I would appreciate it. Greetings Kleiner Greetings Kleiner Edited November 15, 2004 by Kleiner Link to comment Share on other sites More sharing options...
SlimShady Posted November 15, 2004 Share Posted November 15, 2004 (edited) expandcollapse popupGuiCreate ("DBC-Installation", 526, 428, (@DesktopWidth - 526) / 2, (@DesktopHeight - 428) / 2, 0x04CF0000) $CHECKBOX_1 = GUICtrlCreatecheckbox ("DBC-Zertifikat", 20, 10, 90, 40) $CHECKBOX_2 = GUICtrlCreatecheckbox ("FileZilla", 20, 40, 90, 40) $BUTTON_1 = GUICtrlCreatebutton ("Start Installation", 400, 300, 100, 40) GuiSetState (@SW_SHOW) Dim $arguments $msg = 0 While $msg <> -3 $msg = GuiGetMsg() Select Case $msg = $button_1 $arg1 = "" $arg2 = "" If GuiRead($CHECKBOX_1) = 1 Then $arg1 = "_installscript_dbc_zertifikat.exe" If GuiRead(GuiRead($CHECKBOX_2)) = 1 Then $arg2 = "_installscript_filezilla.exe" If $arg1 <> "" AND $arg2 <> "" Then $arguments = $arg1 & ' ' & $arg2 ElseIf $arg1 <> "" Then $arguments = $arg1 ElseIf $arg2 <> "" Then $arguments = $arg2 Else $arguments = "" EndIf If $arguments <> "" Then Run(@ComSpec & " /c " & @ScriptDir & "\runme.bat " & $arguments) EndIf ;;; ;Case $MSG = $PIC_1 ;;; EndSelect Wend Edited November 15, 2004 by SlimShady Link to comment Share on other sites More sharing options...
Kleiner Posted November 16, 2004 Author Share Posted November 16, 2004 Hello again, my script is growing and working as well. But it's not very comfortable. Could anybody help me with reducing or lines and increasing the speed. Problem concerning speed. Each time no checkbox is selected an empty.exe file will be executed. If you only need to Install the last item for example, the pc spends a lot of time doing nearly nothing. Thanks and Greetings Kleiner expandcollapse popupGuiCreate ("DBC-Installation BETA 0.3", 526, 400, (@DesktopWidth - 526) / 2, (@DesktopHeight - 400) / 2, 0x04CF0000) $CHECKBOX_1 = GUICtrlCreatecheckbox ("BG-Info", 20, 10, 150, 40) $CHECKBOX_6 = GUICtrlCreatecheckbox ("New SID", 20, 40, 150, 40) $CHECKBOX_2 = GUICtrlCreatecheckbox ("DBC-Zertifikat", 20, 70, 150, 40) $CHECKBOX_9 = GUICtrlCreatecheckbox ("Java Runtime *", 20, 100, 150, 40) $CHECKBOX_8 = GUICtrlCreatecheckbox ("Office 2000 Standard *", 20, 130, 150, 40) $CHECKBOX_10 = GUICtrlCreatecheckbox ("Acrobat Reader *", 350, 10, 150, 40) $CHECKBOX_3 = GUICtrlCreatecheckbox ("FileZilla", 350, 40, 150, 40) $CHECKBOX_4 = GUICtrlCreatecheckbox ("WinZip", 350, 70, 150, 40) $CHECKBOX_7 = GUICtrlCreatecheckbox ("Quicktime", 350, 100, 150, 40) $CHECKBOX_11 = GUICtrlCreatecheckbox ("Flash-Player", 350, 130, 150, 40) $CHECKBOX_12 = GUICtrlCreatecheckbox ("Shockwave-Player", 350, 160, 150, 40) $CHECKBOX_5 = GUICtrlCreatecheckbox ("Photoshop Elements", 350, 190, 150, 40) $CHECKBOX_13 = GUICtrlCreatecheckbox ("Belarc", 350, 250, 150, 40) $BUTTON_1 = GUICtrlCreatebutton ("Start Installation", 400, 350, 100, 40) GuiSetState (@SW_SHOW) $msg = 0 While $msg <> -3 $msg = GuiGetMsg() Select case $msg = $button_1 $state1 = GuiRead($CHECKBOX_1) $state2 = GuiRead($CHECKBOX_2) $state3 = GuiRead($CHECKBOX_3) $state4 = GuiRead($CHECKBOX_4) $state5 = GuiRead($CHECKBOX_5) $state6 = GuiRead($CHECKBOX_6) $state7 = GuiRead($CHECKBOX_7) $state8 = GuiRead($CHECKBOX_8) $state9 = GuiRead($CHECKBOX_9) $state10 = GuiRead($CHECKBOX_10) $state11 = GuiRead($CHECKBOX_11) $state12 = GuiRead($CHECKBOX_12) $state13 = GuiRead($CHECKBOX_13) if $state1 = 1 Then $arg1 = "_installscript_bginfo.bat" Else $arg1 = "empty.exe" EndIf if $state2 = 1 Then $arg2 = "_installscript_dbc_zertifikat.exe" Else $arg2 = "empty.exe" EndIf If $state3 = 1 Then $arg3 = "_installscript_filezilla.bat" Else $arg3 = "empty.exe" EndIf If $state4 = 1 Then $arg4 = "_installscript_winzip.exe" Else $arg4 = "empty.exe" EndIf If $state5 = 1 Then $arg5 = "_installscript_photoshopelements.exe" Else $arg5 = "empty.exe" EndIf If $state6 = 1 Then $arg6 = "_installscript_newsid.exe" Else $arg6 = "empty.exe" EndIf If $state7 = 1 Then $arg7 = "_installscript_quicktime.exe" Else $arg7 = "empty.exe" EndIf If $state8 = 1 Then $arg8 = "_installscript_office2000standard.exe" Else $arg8 = "empty.exe" EndIf If $state9 = 1 Then $arg9 = "_installscript_java.exe" Else $arg9 = "empty.exe" EndIf If $state10 = 1 Then $arg10 = "_installscript_acrobatreader.exe" Else $arg10 = "empty.exe" EndIf If $state11 = 1 Then $arg11 = "_installscript_flashplayer.exe" Else $arg11 = "empty.exe" EndIf If $state12 = 1 Then $arg12 = "_installscript_shockwave.exe" Else $arg12 = "empty.exe" EndIf If $state13 = 1 Then $arg13 = "_installscript_belarc_printer_install.bat" Else $arg13 = "empty.exe" EndIf Runwait($arg1) Runwait($arg6) Runwait($arg2) Runwait($arg9) Runwait($arg10) Runwait($arg3) Runwait($arg4) Runwait($arg8) Runwait($arg7) Runwait($arg11) Runwait($arg12) Runwait($arg5) Runwait($arg13) EndSelect Wend Exit Link to comment Share on other sites More sharing options...
SlimShady Posted November 16, 2004 Share Posted November 16, 2004 (edited) I made a shorter version for you. I hope the order of the execution of the files doesn't matter. Cause else I couldn't make it this short. [code removed because of the width] Edited November 16, 2004 by SlimShady Link to comment Share on other sites More sharing options...
rmorrow Posted December 9, 2004 Share Posted December 9, 2004 How about creating a comma or tab separated values file on the network that has a list of machine names and each one's options? For instance, you have 15 scripts that will either run or not run depending on the machine name. Use something like: "MACHINE1",1,1,0,1,1,1,0,0,1,1,0,0,0,1,0 "MACHINE2",1,0,1,1,1,0,0,1,1,0,0,0,1,0,1 "MACHINE3",0,1,1,1,0,0,1,1,0,0,0,1,0,1,0 Have your script read the file, comparing the computer's name to the first entry on the line. If it matches, read the options, which are true or false for running each script, and run them accordingly. In this example, machines 1 and 2 would run script 1, but machine 3 would not. Machines 1 and 3 would run script 2, but machine 2 would not. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now