ViciousXUSMC Posted June 5, 2019 Share Posted June 5, 2019 Context: I am looking to create a GUI that offers the name of software and a checkbox that you can check to install it. Easy enough for me to write, and I have done it in the past. However I wrote the GUI, and if things changed I updated the GUI. I have a new job and while they will let me use AutoIT for some things, when possible it needs to be something that anybody on the staff can update/change. So rather than being in a situation where new software or removing old software requires new code and re-compiling. I wanted to find a way to feed an input file and have it dynamically generate a GUI so that the .exe never changes. Simply editing the input file is all that is needed. Extended Context: This is going to run with SCCM for OSD deployment, it wont need to generate crazy amounts of install parameters and paths. I simply need a name of software, and a simple action that sets a breadcrumb like a file, or registry key that the SCCM task sequence will then check later and see if the condition is true to install the software. I can probably create a large GUI with some crude input file that says create a new checkbox and a new label for each item in an array (input file) and just add X to the position of the element for each additional item. But this is crude and will never accommodate x and y coordinates very well especially based on different resolutions. Before I start on that kind of solution, I wanted to see if there is a smart way to do it that I have not even thought of or didn't know about. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted June 5, 2019 Moderators Share Posted June 5, 2019 Just trying to understand your workflow. So the HD user or whomever launches the GUI, selects OSD and then chooses which applications will be pushed once the OS comes down? Is that correct? "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 More sharing options...
ViciousXUSMC Posted June 5, 2019 Author Share Posted June 5, 2019 OSD gets kicked off, there will be a GUI that comes up with a list of optional software. I want them to be able to choose what optional software they want installed. Latter based on what ever breadcrumb I write the OSD will install that software. I wrote something like this at my last job for a Dell K2000 and it was a 3 step process. GUI that set a breadcrumb file to the X: (the PBE) Then a 2nd script that ran after the OS was applied before reboot and exit of the PBE that would copy that breadcrumb to the 😄 Then a 3rd script that would read the breadcrumb and install the files. I think i can make it much simpler with SCCM because I can make the task sequence itself do the software install and set a install condition to check for my breadcrumb. I also think I can skip needing a 2 stage process between PBE and OS by using task sequence variables (Microsoft.SMS.TSEnvironment). Maybe so that I do not have to worry about placement of labels and checkboxes in the GUI I should try something like a listbox, and have them just click on the software name and add it to another data field, then when the GUI exits everything in that 2nd data field will create a TS variable, then the actual OSD just checks to see if that variable exists to install the software. So currently I am researching how to write TSEnvironment variables using AutoIT and how I can "add" items from a listbox to another element in a GUI. It's about go home time, so I will see what I come up with tomorrow. Link to comment Share on other sites More sharing options...
Sidley Posted June 6, 2019 Share Posted June 6, 2019 IniRead/IniReadSection might do the job. Just update the ini file with the software title and path when you need to add new ones. Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted June 7, 2019 Author Share Posted June 7, 2019 (edited) I can not compile due to line 3 of this: $Var = "Custom1" $SCCM = ObjCreate("Microsoft.SMS.TSEnvironment") $VarResult = $SCCM.Value($Var) I assume I need to turn off some sort of syntax check to proceed? Edit: nvm was a hidden space after the brackets. As for how to set the variable (not just read it) Would that be as simple as? $SCCM.Value($Var) = "MyValue" Edited June 7, 2019 by ViciousXUSMC Link to comment Share on other sites More sharing options...
Subz Posted June 9, 2019 Share Posted June 9, 2019 It should be something like, we use something similar but vbscript. Local $sTSVarName_Autoitv3 = "Autoitv3" Local $vTSVarValue_Autoitv3 = "true" Local $oTSEnvironment = ObjCreate("Microsoft.SMS.TSEnvironment") ;~ Create a Variable Local $oTSEnvironment($sTSVarName_Autoitv3) = $vTSVarValue_Autoitv3 ;~ Read an Existing Variable ;~ $sTSVarName_Autoitv3 = $oTSEnvironment($sTSVarName_Autoitv3) Link to comment Share on other sites More sharing options...
benners Posted June 17, 2019 Share Posted June 17, 2019 I posted something similar here you might be able to get some ideas Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted June 17, 2019 Author Share Posted June 17, 2019 I got my GUI together actually just earlier today. Now I need to figure out the object part. Subz probably has it right above you. It was throwing me errors but I think its due to how I had the wrong compiled version for a PBE a 32bit compiled .exe wont work in a 64bit PBE 😕 Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted June 17, 2019 Author Share Posted June 17, 2019 So maybe I should start a new thread in general help as I did get my GUI working but I am still having issues with syntax for creating the task sequence variables. I tried to use AutoIT just to handle creating these with powershell because that is a confirmed syntax I can find online but I discovered our PBE does not have powershell. So went back to trying to do this with pure autoit and what I get is the following errors. Trying to run from SCITE: syntax error statement cannot be just an expression. If I compile it and run it (and same error I get in an actual task sequence) error: no varible given for Dim, Local, Global, Strut or Const statement. Here is my code: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <File.au3> GLOBAL $sProgramList = @ScriptDir & "\DynamicProgramList.txt" GLOBAL $sTSVariable = @ScriptDir & "\CreateTSVariable.ps1" GLOBAL $aListFinal LOCAL $aList LOCAL $sList #Region ### START Koda GUI section ### Form=C:\Users\mosleyp\Desktop\Dynamic Task Sequence\Form1.kxf $Form1 = GUICreate("BoCC Automation", 615, 437, 192, 124, -1, BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE)) $Label1 = GUICtrlCreateLabel("Dynamic Task Sequence", 192, 8, 201, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $List1 = GUICtrlCreateList("", 8, 64, 241, 318, BitOr($GUI_SS_DEFAULT_LIST, $LBS_MULTIPLESEL)) $List2 = GUICtrlCreateList("", 353, 65, 241, 318) $Button1 = GUICtrlCreateButton("ADD", 264, 136, 75, 25) $Button2 = GUICtrlCreateButton("CLEAR", 264, 272, 75, 25) $Button3 = GUICtrlCreateButton("Start Task Sequence", 56, 400, 507, 25) $Label2 = GUICtrlCreateLabel("Step 1: Click To Select Items", 62, 47, 141, 17) $Label3 = GUICtrlCreateLabel("Step 2", 286, 120, 51, 17) $Label4 = GUICtrlCreateLabel("Step 3", 286, 384, 35, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### If NOT FileExists($sProgramList) Then MsgBox($MB_OK, "BOCC Automation", "Missing DynamicProgramList.txt input file Exiting") Exit EndIf _FileReadToArray($sProgramList, $aList, $FRTA_NOCOUNT) $sList = _ArrayToString($aList, "|") GUICtrlSetData($List1, $sList, "") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 _AddItems() Case $Button2 GUICtrlSetData($List2, "", "") Case $Button3 ExitLoop EndSwitch WEnd $iCnt = _GUICtrlListBox_GetCount($List2) For $i = 0 To $iCnt -1 Local $sTSVarName_Autoitv3 = _GUICtrlListBox_GetText($List2, $i) Local $vTSVarValue_Autoitv3 = "true" Local $oTSEnvironment = ObjCreate("Microsoft.SMS.TSEnvironment") Local $oTSEnvironment($sTSVarName_Autoitv3) = $vTSVarValue_Autoitv3 Next Func _AddItems() $aList = _GUICtrlListBox_GetSelItemsText($List1) $sList = _ArrayToString($aList, "|", 1, -1) GUICtrlSetData($List2, $sList, "") EndFunc #cs POWERSHELL $tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment $tsenv.Value("NameofVariable") = "value" #CE #CS Local $sTSVarName_Autoitv3 = "Autoitv3" Local $vTSVarValue_Autoitv3 = "true" Local $oTSEnvironment = ObjCreate("Microsoft.SMS.TSEnvironment") ;~ Create a Variable Local $oTSEnvironment($sTSVarName_Autoitv3) = $vTSVarValue_Autoitv3 ;~ Read an Existing Variable ;~ $sTSVarName_Autoitv3 = $oTSEnvironment($sTSVarName_Autoitv3) #CE For the Powershell version I had pretty much the same except a powershell template that I would replace the values as needed. I might inject powershell into our PBE but if I can get this working without it, that would be MUCH better! Link to comment Share on other sites More sharing options...
BrewManNH Posted June 17, 2019 Share Posted June 17, 2019 For $i = 0 To $iCnt -1 Local $sTSVarName_Autoitv3 = _GUICtrlListBox_GetText($List2, $i) Local $vTSVarValue_Autoitv3 = "true" Local $oTSEnvironment = ObjCreate("Microsoft.SMS.TSEnvironment") Local $oTSEnvironment($sTSVarName_Autoitv3) = $vTSVarValue_Autoitv3 Next Don't declare your variables in a loop like this. Declare them once, then set the values to the variables in your loop. Also, why are you mixing Global and Local declarations in the Global scope? They're all global, declare them with the correct keyword, especially since what you declared as local are actually global variables because you're using them inside the function. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted June 17, 2019 Author Share Posted June 17, 2019 (edited) Just Testing That part was a copy/paste from Subz above, so yeah it needs clean up. I do not see changing scope fixing my issue however, that is why I have not gotten to the "cleanup" phase yet. Let me see how it affects it however once I do. Edit: Mark as resolved! Changed everything around and it's working Edited June 18, 2019 by ViciousXUSMC 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