lordofthestrings Posted April 26, 2007 Share Posted April 26, 2007 (edited) Hi everyone reading these forums.. here goes.. I have written a template for software installation + application to install these packages to the localhost or a remote computer. this uses silent installation method for applications.. 80 % of all applications you will ever come across you can install automatic and remote using this tool.. if you allready have an MSI, great... if you dont you can try installshield installers (setup.exe) these can record every option you configure during installation (setup -r), if that doesnt work theres allways the autoIT au3 recorder...this will solve up to around 99.9 % of all application installations. I used only autoIT to Accomplish every task heres a list of features I came up with.. Application Installation Template: - Command line parameters can be passed to script. (/Install or /Uninstall) - verify if application is installed, and mail results to adress of choice.. - Logging on the computer..(this I can do alot better, but its allready functional) - Errorhandling example from the helpfiles.. Application installer: - read dropdown list items from config.ini file - possibility to install the applications local or remote - to install remote you can use the current logged on users' credentials, or you can specify another user in the config file ( if you enable the advanced section in the ini file.. once you do, you'll get a password prompt so sensitive info is not stored in plain text..) - to install remotely I use ONLY WMI code.. Hope this helps others getting up and running with AutoIT.. kind regards, LOTS...LOTS_ApplicationInstaller.zip Edited April 27, 2007 by lordofthestrings Link to comment Share on other sites More sharing options...
mikiutama Posted April 26, 2007 Share Posted April 26, 2007 i got error with SetupApplication.au3 ==> Variable used without being declared.: $Text1 = GUICtrlCreateLabel($installing, 16, 24, 111, 19) $Text1 = GUICtrlCreateLabel(^ ERROR Link to comment Share on other sites More sharing options...
lordofthestrings Posted April 27, 2007 Author Share Posted April 27, 2007 for applications you'll need to edit the template here's two examples (that were supposed to come with the package but I forgot..) ; --------------------------------------------------------------------------------------------- $File = "\\mmmstn001\#######$\My Pictures\logo.GIF" $MailTo = 'BLAAT@MAILINATOR.COM' $MailSubject = 'Results on' & @ComputerName & ' // installation by: ' & @UserName $InstallString = @SystemDir & "msiexec.exe /I " & @ScriptDir & '\Install' & "\python.msi" $UninstallString = "msiexec /QB /X{0A2C5854-557E-48C8-835A-3B9F074BDCAA}" $Application = 'C:\Python25' $AppName = "python-2.5" $Gui_Title = "" ; --------------------------------------------------------------------------------------------- you will have to download python from their website for this one to work.. another one would be a bit different (my second testcase for this template) acrobat reader 8.0 download it, run it but do not click next on the welcome screen. once you see this window, you will need to open explorer and browse to your %TMP% folder there you will see an acrobat folder with in it the extracted acroreader.msi this folder will be your source, (not the one executable, if you find an MSI its better.. heres the template code for acrobat reader ; --------------------------------------------------------------------------------------------- $File = "\\mmmstn001\#####$\My Pictures\logo.GIF" $Application = 'C:\Program Files\Adobe\Reader 8.0\' $AppName = "AcrobatReader8" $Gui_Title = "" $MailTo = 'BLAAT@MAILINATOR.COM' $MailSubject = 'Results on' & @ComputerName & ' // installation by: ' & @UserName $InstallString = 'msiexec /QB /I AcroRead.msi' $UninstallString = "msiexec /QB /X{AC76BA86-7AD7-1033-7B44-A80000000002}" ; --------------------------------------------------------------------------------------------- with these 2 examples you should be able to get it to work, and future applications shouldnt be too hard either.. this is still in development fase, but it allready works (I hope,...) Link to comment Share on other sites More sharing options...
lordofthestrings Posted April 27, 2007 Author Share Posted April 27, 2007 (edited) heres the adjusted code that should take care of your error... (I added the new code to the attachement in the first post) I hope you get it to work expandcollapse popup#include <INet.au3> #Include <Date.au3> #include <Constants.au3> #include <GuiConstants.au3> $oMyError = ObjEvent("AutoIt.Error","ErrHandler") if NOT $CMDLINE[0] = 0 Then if $CMDLINE[1] = '/Install' or $CMDLINE[1] = '/I' or $CMDLINE[1] = '/s' Then $installing = "currently installing:" Else $installing = "currently removing:" endIf Else $installing = '' EndIf $Key = "HKEY_CURRENT_USER\Software\Microsoft\windows\currentversion\Policies\System" $Log_Str_File = "c:\application\log\" & $AppName & '.txt' $Log_Reinst_Str_File = "c:\application\Reinstall-PC\" & $AppName & '.txt' #region #@#@# Form Designed with Koda Form Designer, but changed the hardcoded entries to variables GuiCreate($Gui_Title, 418, 97, 565, 614, BitOR($WS_CAPTION,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE)) $Picture = GUICtrlCreatePic($File, 224, 8, 180, 68, BitOR($SS_NOTIFY,$WS_GROUP)) $LogoPane = GUICtrlCreateGroup("", 216, 0, 193, 81) GUICtrlCreateGroup("", -99, -99, 1, 1) $Text1 = GUICtrlCreateLabel($installing, 16, 24, 111, 19) GUICtrlSetFont(-1, 9, 800, 0, "Times New Roman") $Text2 = GUICtrlCreateLabel($AppName, 16, 56, 172, 27) GUICtrlSetFont(-1, 12, 400, 4, "Arial Black") GUICtrlSetColor(-1, 0x0000FF) GUISetState(@SW_SHOW) #endregion ### koda form designer is quick and easy; run koda --> design form --> run form --> get the code.. GuiSetState() $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Case Else $tmp = "" ; Here I would Insert functionality into the installation ;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ; AdlibEnable("errorBoxes", 300) ;run checkerrorwindows function every 300 Milliseconds. check_Arguments() ; check wether to /install or /uninstall argument has been provided. RunWait($RunThis,"",@SW_HIDE) ; installation or uninstallation of application. ; shutdown(6) ; Force to reboot the PC Verify_and_mail() ; check if application is installed + logging + Mailing. ;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ EndSelect MsgBox(0, "", "Installation has finished", 1) Exit Func check_Arguments() if NOT $CMDLINE[0] = 0 Then if not StringIsUpper($CMDLINE[1]) Then StringUpper($CMDLINE[1]) endIf select case $CMDLINE[0] = 0 ; case : No arguments specified msgbox(0, "syntax", "please provide switch:" & @CRLF & @CRLF & @TAB & _ "/install or /i or /s" & @CRLF & @TAB & _ "/Uninstall or /x or /u" , 7) LogMsg("No Arguments were specified for " & $AppName) exit(3) case $CMDLINE[1] = '/INSTALL' or $CMDLINE[1] = '/S' or $CMDLINE[1] = '/I' or $CMDLINE[1] = '/SILENT' LogMsg("Installation Switch Presented. Starting Installation of " & $AppName) global $RunThis = $InstallString case $CMDLINE[1] = "/UNINSTALL" or $CMDLINE[1] = "/U" or $CMDLINE[1] = "/X" LogMsg("Uninstallation Switch Presented. Starting Uninstallation of " & $AppName) global $RunThis = $UninstallString case Else LogMsg("*** WRONG *** Argument specified for " & $AppName) EndSelect EndFunc func Verify_and_mail() if fileexists($Application) Then $Installed = 'INSTALLED' Else $Installed = 'UNINSTALLED' EndIf $MailBody = 'The application seems to be '& $Installed & @CRLF & 'Application: ' & $Application & 'parameters passed to script: ' & $CMDLINE[1] LogMsg("Mail Sent : Application : " & $Application & " seems " & $Installed) if NOT fileexists($Log_Reinst_Str_File) AND $Installed = 'INSTALLED' Then reinstall_PC_Log() Else FileDelete($Log_Reinst_Str_File) EndIf _INetMail ($MailTo, $MailSubject, $MailBody) endFunc Func LogMsg($LogMSG) $LogFile = FileOpen($Log_Str_File, 9) If $LogFile = -1 Then MsgBox(0, "Error", "Unable to open file.", 2) Exit EndIf FileWriteLine($LogFile, '_______________________________________________________________________') FileWriteLine($LogFile, _Now() & " - " & @Username & " - " & $LogMSG) FileClose($LogFile) EndFunc Func reinstall_PC_Log() $Log_Reinst_File = FileOpen($Log_Reinst_Str_File, 9) If $Log_Reinst_File = -1 Then MsgBox(0, "Error", "Unable to open file.", 2) Exit EndIf FileWriteLine($Log_Reinst_File,"this file will be used to check what applications are installed when reinstalling the PC") FileClose($Log_Reinst_File) EndFunc Func ErrHandler() Msgbox(0,"Com Error","The Script intercepted a COM Error!" & @CRLF & @CRLF & _ "description is: " & @TAB & $oMyError.description & @CRLF & _ "windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "number is: " & @TAB & hex($oMyError.number,8) & @CRLF & _ "lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "source is: " & @TAB & $oMyError.source & @CRLF & _ "helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "helpcontext is: " & @TAB & $oMyError.helpcontext _ ) Local $err = $oMyError.number If $err = 0 Then $err = -1 SetError($err) ; to check for after this function returns Endfunc func errorBoxes() #cs this is a function that will be called at an interval specified in the adlibenable function. mainly use this function to catch "unexpected" windows examples: if WinExists Then do something.. if FileExists Then something else.. if ProcessExists Then final thing.. .... #ce EndFunc Edited April 27, 2007 by lordofthestrings Link to comment Share on other sites More sharing options...
realkiller Posted October 25, 2007 Share Posted October 25, 2007 i just tryed out your remote execute code, it works on 127.0.0.1 but not on a other computer(i am domain admin) $strComputer = "computer" $CommandLine = "cmd" RemoteExecute($strComputer, $CommandLine) func RemoteExecute($strComputer, $CommandLine) ; Simple $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $objShare = $objWMIService.Get("Win32_Process") $objInParam = $objShare.Methods_("Create").inParameters.SpawnInstance_() $objInParam.Properties_.Item("CommandLine") = $CommandLine $objOutParams = $objWMIService.ExecMethod("Win32_Process", "Create", $objInParam) $PID = $objOutParams.ProcessId $ReturnValue = $objOutParams.ReturnValue Switch $ReturnValue Case 0 msgbox(0, "RunRemote","The remote command completed successfully") Case 2 msgbox(0, "RunRemote","Answer from Remote Computer: Access denied") Case 3 msgbox(0, "RunRemote","Insufficient privilege to launch remote command") Case 8 msgbox(0, "RunRemote","Unknown failure") Case 9 msgbox(0, "RunRemote","Path not found") Case 21 msgbox(0, "RunRemote","Invalid parameter passed to script: " & @CRLF & _ "$strComputer: " & $strComputer & @CRLF & _ "$CommandLine: " & $CommandLine) Case Else msgbox(0, "RunRemote","Unknown error" & @CRLF & _ "ResultCode: " & $ReturnValue) EndSwitch EndFunc Remote 3.1 BetaRemote Media Player ControlUSB Security 1.2 Link to comment Share on other sites More sharing options...
spudw2k Posted November 27, 2007 Share Posted November 27, 2007 WMI doesn't support running interactive processes. You have to use addtional software to remotely execute something that requires user intervention. It's also possible that if the remote machine is locked, some things will hang on this as well. I use PSEXEC to get around this. Let me know if you need a hand. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF  Link to comment Share on other sites More sharing options...
tiuk Posted February 12, 2009 Share Posted February 12, 2009 Hi there. I realize this is an old topic, but I need to set up a large amount of remote application installs and this seems to be a pretty good starting point, or would be if I could get the script to compile Here are the errors and warnings I get: expandcollapse popupC:\Documents and Settings\sysadmin\Desktop\LOTS_ApplicationInstaller\SetupApplication.au3(34,55) : ERROR: syntax error GUICreate($Gui_Title, 418, 97, 565, 614, BitOR(Caption, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Documents and Settings\sysadmin\Desktop\LOTS_ApplicationInstaller\SetupApplication.au3(34,66) : WARNING: $WS_BORDER: possibly used before declaration. GUICreate($Gui_Title, 418, 97, 565, 614, BitOR(Caption,$WS_BORDER, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Documents and Settings\sysadmin\Desktop\LOTS_ApplicationInstaller\SetupApplication.au3(34,83) : WARNING: $WS_CLIPSIBLINGS: possibly used before declaration. GUICreate($Gui_Title, 418, 97, 565, 614, BitOR(Caption,$WS_BORDER,$WS_CLIPSIBLINGS) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Documents and Settings\sysadmin\Desktop\LOTS_ApplicationInstaller\SetupApplication.au3(34,103) : WARNING: $WS_CAPTION: possibly used before declaration. GUICreate($Gui_Title, 418, 97, 565, 614, BitOR(Caption,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR($WS_CAPTION, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~^ C:\Documents and Settings\sysadmin\Desktop\LOTS_ApplicationInstaller\SetupApplication.au3(34,154) : WARNING: $WS_EX_TOPMOST: possibly used before declaration. GUICreate($Gui_Title, 418, 97, 565, 614, BitOR(Caption,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR($WS_CAPTION,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR($WS_EX_TOPMOST, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Documents and Settings\sysadmin\Desktop\LOTS_ApplicationInstaller\SetupApplication.au3(34,172) : WARNING: $WS_EX_WINDOWEDGE: possibly used before declaration. GUICreate($Gui_Title, 418, 97, 565, 614, BitOR(Caption,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR($WS_CAPTION,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Documents and Settings\sysadmin\Desktop\LOTS_ApplicationInstaller\SetupApplication.au3(35,69) : WARNING: $SS_NOTIFY: possibly used before declaration. $Picture = GUICtrlCreatePic($File, 224, 8, 180, 68, BitOR($SS_NOTIFY, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Documents and Settings\sysadmin\Desktop\LOTS_ApplicationInstaller\SetupApplication.au3(35,79) : WARNING: $WS_GROUP: possibly used before declaration. $Picture = GUICtrlCreatePic($File, 224, 8, 180, 68, BitOR($SS_NOTIFY,$WS_GROUP) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Documents and Settings\sysadmin\Desktop\LOTS_ApplicationInstaller\SetupApplication.au3(55,17) : WARNING: $RunThis: possibly used before declaration. RunWait($RunThis, ~~~~~~~~~~~~~~~~^ C:\Documents and Settings\sysadmin\Desktop\LOTS_ApplicationInstaller\SetupApplication.au3(34,66) : ERROR: $WS_BORDER: undeclared global variable. GUICreate($Gui_Title, 418, 97, 565, 614, BitOR(Caption,$WS_BORDER, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Documents and Settings\sysadmin\Desktop\LOTS_ApplicationInstaller\SetupApplication.au3 - 2 error(s), 8 warning(s) Where are these variables supposed to be defined? I am missing something here? I'm new to AutoIt and haven't done much GUI work so I can't just define them myself, I don't know what the values should be. Any help would be appreciated, thanks. 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