Sign in to follow this  
Followers 0
dufran3

Care to critique my script?

3 posts in this topic

Here is an auto-install script i've been working on for some time. It does what I need so far. Is there anything severly wrong w/ my logic or methods?

#CS
    Rapid Deployment Tool Application Installer
    
    Author: Me
    
    Description:
    The purpose of this script is to setup and customize a computer before deployment.
    There are options that let you choose what to install and what not to install.
    
    License:  This script can be freely copied and distributed, as long as it is not
    sold for ANY fee (including "distribution" costs.)  Any modification to
    this script must be submitted to the original author if the modified script
    is distributed in any manner.  Any modification must include this header
    information with this licence, disclaimer and original author information in tact.
    
    Disclaimer: The author is not responsible for any damage or harm caused by this
    script.  USE AT YOUR OWN RISK.  There is no warranty, expressed or implied.
    
    - Version 0.2: Removed logging to decrease size of file
    - Version 0.3: Removed redundant and unnecessary code to reduce size
                   - Modified iTunes installer to be more efficient
#CE

#include <GUIConstantsEx.au3>
#include <XSkin.au3>
#include <Log_Functions.au3>
#include <_ButtonHover.au3>

Opt("GUIOnEventMode", 1)

;Variables
$Skin_Folder = 'C:\Temp\xSkin'
$TempFolder = 'C:\Temp\EWUAI\'
$InstallerTempFolder = $TempFolder & 'Installers\'
$TempFolder_Icons = $TempFolder & 'icons\'
$XButton_Location = $Skin_Folder
Global $InstallSource = '\\146.187.7.66\Public\RDT\Installers\'
;Global $Debug = 3 ;1 = normal debug 2 = strong 0 = no debug
;/Variables

;Read in .ini values
$VersionFileRead = '\\146.187.7.66\Public\RDT\Version.ini'
$VersionFileNotFound = ' *Version Missing*'
;Debug Level
Global $Debug = IniRead($VersionFileRead, 'Debug', 'Level', $VersionFileNotFound)
;Adobe Acrobat Reader
Global $AcrobatVer = IniRead($VersionFileRead, 'Adobe Acrobat Reader', 'Version', $VersionFileNotFound)
Global $AcrobatFileName = IniRead($VersionFileRead, 'Adobe Acrobat Reader', 'Filename', 'Not Found')
;Adobe Flash Player
Global $AdobeFlashVer = IniRead($VersionFileRead, 'Adobe Flash Player', 'Version', $VersionFileNotFound)
Global $FlashFileName1 = IniRead($VersionFileRead, 'Adobe Flash Player', 'FileName1', 'Not Found')
Global $FlashFileName2 = IniRead($VersionFileRead, 'Adobe Flash Player', 'FileName2', 'Not Found')
;Itunes and QuickTime
Global $iTunesVer = IniRead($VersionFileRead, 'iTunes', 'Version', $VersionFileNotFound)
Global $iTunesFileName = IniRead($VersionFileRead, 'iTunes', 'FileName1', 'Not Found')
Global $QuickTimeFileName = IniRead($VersionFileRead, 'iTunes', 'FileName2', 'Not Found')
Global $AppleAppSupportFileName = IniRead($VersionFileRead, 'iTunes', 'FileName3', 'Not Found')
Global $SoftwareUpdateFileName = IniRead($VersionFileRead, 'iTunes', 'FileName4', 'Not Found')
Global $BonjourFileName = IniRead($VersionFileRead, 'iTunes', 'FileName5', 'Not Found')
;Java
Global $JavaVersion = IniRead($VersionFileRead, 'Java', 'Version', $VersionFileNotFound)
Global $JavaFileName = IniRead($VersionFileRead, 'Java', 'FileName', 'Not Found')
;Firefox
Global $FirefoxVer = IniRead($VersionFileRead, 'Firefox', 'Version', $VersionFileNotFound)
Global $FirefoxFileName = IniRead($VersionFileRead, 'Firefox', 'Filename', 'Not Found')
;Office
Global $OfficeVer = IniRead($VersionFileRead, 'Office', 'Version', $VersionFileNotFound)
Global $OfficeFileName = IniRead($VersionFileRead, 'Office', 'Filename', 'Not Found')
;VLC
Global $VLCVer = IniRead($VersionFileRead, 'VLC', 'Version', $VersionFileNotFound)
Global $VLCFileName = IniRead($VersionFileRead, 'VLC', 'FileName', 'Not Found')
;Domain Tools
Global $DomainToolsFolderName = IniRead($VersionFileRead, 'Domain Tools', 'Foldername', 'Not Found')
Global $DomainToolsFileName = IniRead($VersionFileRead, 'Domain Tools', 'Filename', 'Not Found')
;Trend Micro
Global $TrendMicroVersion = IniRead($VersionFileRead, 'TrendMicro', 'Version', $VersionFileNotFound)
Global $TrendMicroFileName = IniRead($VersionFileRead, 'TrendMicro', 'Filename', 'Not Found')
Global $TrendMicroPath = IniRead($VersionFileRead, 'TrendMIcro', 'Path','Not Found')
DirCreate($TempFolder)
DirCreate($TempFolder_Icons)
Global $LogFileOpen = FileOpen('C:\Temp\EWUAI\EWUAISetup.log', 1)

;Write Log File Header
_WriteLogFile($LogFileOpen, '-------------------------------------------------------')
_WriteLogFile($LogFileOpen, 'Starting script ' & @MON & "-" & @MDAY & "-" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC & @CRLF)
_WriteLogFile($LogFileOpen, "Started by user: " & @UserName)

;Check if Xskin directory exists
If Not FileExists('C:\Temp\Xskin') Then
    DirCreate('C:\Temp\Xskin')
EndIf

;Install Files to Temp Directory
FileInstall('C:\Documents and Settings\sandek\Desktop\!Scripts\EWU App Installer\xSkin\0.bmp', $Skin_Folder & '\0.bmp', 1)
FileInstall('C:\Documents and Settings\sandek\Desktop\!Scripts\EWU App Installer\xSkin\1.bmp', $Skin_Folder & '\1.bmp', 1)
FileInstall('C:\Documents and Settings\sandek\Desktop\!Scripts\EWU App Installer\xSkin\2.bmp', $Skin_Folder & '\2.bmp', 1)
FileInstall('C:\Documents and Settings\sandek\Desktop\!Scripts\EWU App Installer\xSkin\3.bmp', $Skin_Folder & '\3.bmp', 1)
FileInstall('C:\Documents and Settings\sandek\Desktop\!Scripts\EWU App Installer\xSkin\4.bmp', $Skin_Folder & '\4.bmp', 1)
FileInstall('C:\Documents and Settings\sandek\Desktop\!Scripts\EWU App Installer\xSkin\5.bmp', $Skin_Folder & '\5.bmp', 1)
FileInstall('C:\Documents and Settings\sandek\Desktop\!Scripts\EWU App Installer\xSkin\6.bmp', $Skin_Folder & '\6.bmp', 1)
FileInstall('C:\Documents and Settings\sandek\Desktop\!Scripts\EWU App Installer\xSkin\7.bmp', $Skin_Folder & '\7.bmp', 1)
FileInstall('C:\Documents and Settings\sandek\Desktop\!Scripts\EWU App Installer\xSkin\skin.dat', $Skin_Folder & '\skin.dat', 1)
FileInstall('C:\Documents and Settings\sandek\Desktop\!Scripts\EWU App Installer\xSkin\logo.jpg', $Skin_Folder & '\logo.jpg', 1)
FileInstall('C:\Documents and Settings\sandek\Desktop\!Scripts\EWU App Installer\xSkin\over.jpg', $Skin_Folder & '\over.jpg', 1)
FileInstall('C:\Documents and Settings\sandek\Desktop\!Scripts\EWU App Installer\xSkin\press.jpg', $Skin_Folder & '\press.jpg', 1)
FileInstall('C:\Documents and Settings\sandek\Desktop\!Scripts\EWU App Installer\xSkin\normal.jpg', $Skin_Folder & '\normal.jpg', 1)
FileInstall('C:\Documents and Settings\sandek\Desktop\!Scripts\EWU App Installer\xSkin\logo.jpg', $Skin_Folder & '\logo.jpg', 1)
FileInstall('C:\Documents and Settings\sandek\Desktop\!Scripts\EWU App Installer\icons\Acrobat.ico', $TempFolder_Icons & '\Acrobat.ico', 1)
FileInstall('C:\Documents and Settings\sandek\Desktop\!Scripts\EWU App Installer\icons\Flash.ico', $TempFolder_Icons & '\Flash.ico', 1)
FileInstall('C:\Documents and Settings\sandek\Desktop\!Scripts\EWU App Installer\icons\Firefox.ico', $TempFolder_Icons & '\Firefox.ico', 1)
FileInstall('C:\Documents and Settings\sandek\Desktop\!Scripts\EWU App Installer\icons\Office07.ico', $TempFolder_Icons & '\Office07.ico', 1)
FileInstall('C:\Documents and Settings\sandek\Desktop\!Scripts\EWU App Installer\icons\terminal.ico', $TempFolder_Icons & '\terminal.ico', 1)
FileInstall('C:\Documents and Settings\sandek\Desktop\!Scripts\EWU App Installer\icons\EWU.ico', $TempFolder_Icons & '\EWU.ico', 1)
FileInstall('C:\Documents and Settings\sandek\Desktop\!Scripts\EWU App Installer\icons\iTunes.ico', $TempFolder_Icons & '\iTunes.ico', 1)
FileInstall('C:\Documents and Settings\sandek\Desktop\!Scripts\EWU App Installer\icons\Java.ico', $TempFolder_Icons & '\Java.ico', 1)
FileInstall('C:\Documents and Settings\sandek\Desktop\!Scripts\EWU App Installer\icons\VLC.ico', $TempFolder_Icons & '\VLC.ico', 1)
FileInstall('C:\Documents and Settings\sandek\Desktop\!Scripts\EWU App Installer\icons\TrendMicro.ico', $TempFolder_Icons & '\TrendMicro.ico', 1)

;Create Xskin GUI
$Main = XSkinGUICreate('EWU-AI', 425, 525, $Skin_Folder)

;Set GUI Options
TraySetIcon($TempFolder_Icons & 'EWU.ico')
GUISetOnEvent($GUI_EVENT_CLOSE, 'SpecialEvents')

;Create Image on GUI
GUICtrlCreatePic($Skin_Folder & '\logo.jpg', 25, 37, 368, 53)


;Create Icons on GUI
GUICtrlCreateIcon($TempFolder_Icons & '\Acrobat.ico', 'Acrobat', 16, 126, 16, 16)
GUICtrlCreateIcon($TempFolder_Icons & '\Flash.ico', 'Flash', 16, 148, 16, 16)
GUICtrlCreateIcon($TempFolder_Icons & '\iTunes.ico', 'iTunes/Quicktime', 16, 170, 16, 16)
GUICtrlCreateIcon($TempFolder_Icons & '\Java.ico', 'Java', 16, 192, 16, 16)
GUICtrlCreateIcon($TempFolder_Icons & '\Office07.ico', 'Office 2007', 16, 214, 16, 16)
GUICtrlCreateIcon($TempFolder_Icons & '\Firefox.ico', 'Mozilla Firefox', 16, 236, 16, 16)
GUICtrlCreateIcon($TempFolder_Icons & '\terminal.ico', 'Active Directory Tools', 16, 258, 16, 16)
GUICtrlCreateIcon($TempFolder_Icons & '\VLC.ico', 'VLC Player', 16, 280, 16, 16)
GUICtrlCreateIcon($TempFolder_Icons & '\TrendMicro.ico', 'Trend Micro', 16, 302, 16, 16)

Dim $aDesktop[9][4] = [ _
        ['Adobe Acrobat Reader ' & $AcrobatVer, '_InstallAcrobat', '0', '0'], _
        ['Adobe Flash Player ' & $AdobeFlashVer, '_InstallFlashPlayer', '0', '0'], _
        ['iTunes and Quicktime ' & $iTunesVer, '_InstalliTunes', '0', '0'], _
        ['Java ' & $JavaVersion, '_InstallJava', '0', '0'], _
        ['Microsoft Office ' & $OfficeVer, '_InstallOffice', '0', '0'], _
        ['Mozilla Firefox ' & $FirefoxVer, '_InstallMozillaFirefox', '0', '0'], _
        ['Domain Tools', '_CopyDomainTools', '0', '0'], _
        ['VLC Media Player ' & $VLCVer, '_InstallVLC', '0', '0'], _
        ['Trend Micro Office Scan ' & $TrendMicroVersion, ' _InstallTrendMicro', '0', '0'] _
        ]

Dim $aDesktopSize = UBound($aDesktop)
Dim $deskXSkinID[($aDesktopSize + 1)]
Dim $DeskCtrl[($aDesktopSize + 1)]

;Create Checkbox
Local $nLeft = 35, $nTop = 125, $nWidth = 200, $nHeight = 20
For $i = 0 To $aDesktopSize - 1
    $DeskCtrl[$i] = GUICtrlCreateCheckbox($aDesktop[$i][0], $nLeft, $nTop, $nWidth + 15, 20)
    If $aDesktop[$i][2] == 1 Then GUICtrlSetState(-1, $GUI_CHECKED)
    $nTop += 22
Next
;/Checkbox

;Buttons
$DesktopStart = _HoverButton('START', 280, 265, 75, 25, 0xFFFFFF)
GUICtrlSetFont($DesktopStart + 1, 8, 600, '', 'Comic Sams')
GUICtrlSetOnEvent($DesktopStart, 'Install')
$DesktopSelect = _HoverButton('SELECT', 280, 310, 75, 25, 0xFFFFFF)
GUICtrlSetFont($DesktopSelect + 1, 8, 600, '', 'Comic Sams')
GUICtrlSetOnEvent($DesktopSelect, '_SelectAll')
$DesktopDeselect = _HoverButton('DESELECT', 280, 355, 75, 25, 0xFFFFFF)
GUICtrlSetFont($DesktopDeselect + 1, 8, 600, '', "Comic Sams")
GUICtrlSetOnEvent($DesktopDeselect, '_DeSelectAll')
$DesktopExit = _HoverButton('EXIT', 280, 400, 75, 25, 0xFFFFFF)
GUICtrlSetFont($DesktopExit + 1, 8, 600, '', 'Comic Sams')
GUICtrlSetOnEvent($DesktopExit, 'Exitier')
_ControlHover(2, "", $DesktopStart)
_ControlHover(2, "", $DesktopSelect)
_ControlHover(2, "", $DesktopDeselect)
_ControlHover(2, "", $DesktopExit)
;/Buttons

GUISetOnEvent($GUI_EVENT_CLOSE, 'exitier', $Main)
GUISetState()

MsgBox(0,'Network Connectivity Requirement','This tool requires network access to the following directory: ' & $InstallSource)

While 1 ;GUIGetMsg() <> $GUI_EVENT_CLOSE
    _CheckHoverAndPressed($Main)
    Sleep(10)
WEnd

FileClose($LogFileOpen)

Func Install()
    ;Debug
    If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'Entering Install function')

    GUISetState(@SW_HIDE, $Main)

    ;Debug
    If $Debug == 3 Then _WriteLogFile($LogFileOpen, 'Entering loop for Application check')
    ;Loop through Desktop Array
    For $i = 0 To $aDesktopSize - 1
        $checkboxstatus = GUICtrlRead($DeskCtrl[$i])
        If ($checkboxstatus == 1) Then
            If $Debug == 3 Then
                _WriteLogFile($LogFileOpen, '"' & $aDesktop[$i][0] & '"' & " has control ID: " & $DeskCtrl[$i] & ' and is checked')
                _WriteLogFile($LogFileOpen, $aDesktop[$i][1] & ' is the function name assigned to control ID: ' & $DeskCtrl[$i])
            EndIf
            If $Debug == 2 Or 3 Then
                _WriteLogFile($LogFileOpen, 'Calling: ' & $aDesktop[$i][1] & ' and passing it: ' & $aDesktop[$i][3])
            EndIf
            If $Debug == 1 Or 2 Or 3 Then _WriteLogFile($LogFileOpen, 'Running: "' & $aDesktop[$i][0] & '"')
            ;Debug Profiling
            $aDesktopStartTime = TimerInit()
            ;Calling Function
            Call($aDesktop[$i][1], $aDesktop[$i][3])
            ;Debug Profiling
            $aDesktopEndTime = Int(TimerDiff($aDesktopStartTime)) / 1000
            ;Writing to Log
            If $Debug == 1 Or 2 Or 3 Then _WriteLogFile($LogFileOpen, 'Function call took: ' & $aDesktopEndTime & ' second(s)')
        EndIf
    Next
    ;Debug
    If $Debug == 1 Or 2 Or 3 Then _WriteLogFile($LogFileOpen, 'Removing Temp Directory: "C:\Temp\Xskin"')

    DirRemove('C:\Temp\Xskin', 1)
    DirRemove($TempFolder_Icons, 1)
    _WriteLogFile($LogFileOpen, 'Exiting Script')
    FileClose($LogFileOpen)
    
    MsgBox(0x40040, 'Automated Install Complete','Script is finished')
    Exit
EndFunc   ;==>Install

Func _InstallAcrobat($flag)
    ;Debug
    If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'Entering _InstallAcrobat Function')
        
    If FileExists(@ProgramFilesDir & '\Adobe\Reader 10.0\Reader\AcroRd32.exe') Then
        _WriteLogFile($LogFileOpen, 'File Exists at: ' & @ProgramFilesDir & '\Adobe\Reader 10.0\Reader\AcroRd32.exe - Skipping Acrobat Install')    
    Else
        Local $Sourcecheck = FileExists($InstallSource & $AcrobatFileName)
        ProgressOn('Adobe Acrobat', 'Installing')
        ProgressSet(50)
        If $Sourcecheck == 1 Then
            FileCopy($InstallSource & $AcrobatFileName, $TempFolder, 1)
            ProgressSet(100)
            If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'Running command: ' & $TempFolder & $AcrobatFileName & ' /sPB')
            RunWait($TempFolder & $AcrobatFileName & ' /sPB')
        Else
            _WriteLogFile($LogFileOpen, 'Source file not found at: ' & $InstallSource & $AcrobatFilename)
        EndIf
    EndIf
    
    ;Cleanup
    FileDelete($TempFolder & $AcrobatFilename)
    ProgressOff()
    
    ;Debug
    If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'Exiting _InstallAcrobat Function')
EndFunc   ;==>_InstallAcrobat

Func _InstallFlashPlayer($flag)
    ;Debug
    If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'Entering _InstallFlashPlayer Function')

    Local $Sourcecheck1 = FileExists($InstallSource & $FlashFileName1)
    Local $Sourcecheck2 = FileExists($InstallSource & $FlashFileName2)
    
    ProgressOn('Adobe Flash Player', 'Installing')
    ProgressSet(25)
    If $Sourcecheck1 == 1 Then
        FileCopy($InstallSource & $FlashFileName1, $TempFolder, 1)
        ProgressSet(50)
        If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'Running command: msiexec /i '  & $TempFolder & $FlashFileName1 & ' /qn')
        RunWait("msiexec /i " & $TempFolder & $FlashFileName1 & ' /qn')
    Else
        _WriteLogFile($LogFIleOpen, 'Source file not found at: ' & $InstallSource & $FlashFileName1)
    EndIf
    
    ProgressSet(75)
    If $Sourcecheck2 == 1 Then
        FileCopy($InstallSource & $FlashFileName2, $TempFolder, 1)
        ProgressSet(100)
        If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'Running command: msiexec /i '  & $TempFolder & $FlashFileName2 & ' /qn')
        RunWait("msiexec /i " & $TempFolder & $FlashFileName2 & ' /qn')
    Else
        _WriteLogFile($LogFileOpen, 'Source file not found at: ' & $InstallSource & $FlashFileName2)
    EndIf
    
    ;Cleanup
    FileDelete($TempFolder & $FlashFileName1)
    FileDelete($TempFolder & $FlashFileName2)
    ProgressOff()
    
    ;Debug
    If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'Exiting _InstallFlashPlayer Function')
EndFunc   ;==>_InstallFlashPlayer

Func _InstallJava($flag)
    ;Debug
    If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'Entering _InstallJava Function')

    Local $Sourcecheck = FileExists($InstallSource & $JavaFileName)
    
    ProgressOn('Java', 'Installing')
    ProgressSet(50)
    If $Sourcecheck == 1 Then
        FileCopy($InstallSource & $JavaFileName, $TempFolder, 1)
        ProgressSet(75)
        If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'Running command: ' & $TempFolder & $JavaFileName & ' /s /qn ADDLOCAL=ALL IEXPLORER=1 MOZILLA=1 SYSTRAY=0 REBOOT=Suppress ')
        RunWait($TempFolder & $JavaFileName & ' /s /qn ADDLOCAL=ALL IEXPLORER=1 MOZILLA=1 SYSTRAY=0 REBOOT=Suppress ')
    Else
        _WriteLogFile($LogFileOpen, 'Source file not found at: ' & $InstallSource & $JavaFileName)
    EndIf
    ProgressSet(100)
    
    ;Cleanup
    FileDelete($TempFolder & $JavaFileName)
    ProgressOff()
    
    ;Debug
    If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'Exiting _InstallJava Function')
EndFunc   ;==>_InstallJava

Func _InstallMozillaFirefox($flag)
    ;Debug
    If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'Entering _InstallMozillaFirefox Function')
        
    Local $Sourcecheck = FileExists($InstallSource & $FirefoxFileName)
    
    ProgressOn('Mozilla Firefox', 'Installing')
    ProgressSet(50)
    If $Sourcecheck == 1 Then
        FileCopy($InstallSource & $FirefoxFileName, $TempFolder, 1)
        ProgressSet(100)
        If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'Running command: ' & '"' & $TempFolder & $FirefoxFileName & '"' & ' /-ms')
        RunWait('"' & $TempFolder & $FirefoxFileName & '"' & ' /-ms')
    Else
        _WriteLogFile($LogFileOpen, 'Source file not found at: ' & $InstallSource & $FirefoxFileName)
    EndIf
    
    ;Cleanup
    FileDelete($Tempfolder & $FirefoxFileName)
    ProgressOff()
    
    ;Debug
    If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'Exiting _InstallMozillaFirefox Function')
EndFunc   ;==>_InstallMozillaFirefox

Func _InstallOffice($flag)
    ;Debug
    If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'Entering _InstallOffice Function')

    Local $Sourcecheck = FileExists($InstallSource & 'Office' & $OfficeVer & '\' & $OfficeFileName)
    
    ProgressOn('Microsoft Office 2007', 'Installing')
    ProgressSet(25)
    If $Sourcecheck == 1 Then
        DirCopy($InstallSource & 'Office' & $OfficeVer, $TempFolder & 'Office' & $OfficeVer & '\', 1)
        ProgressSet(50)
        If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'Running command: ' & $InstallerTempFolder & 'Office' & $OfficeVer & '\' & $OfficeFileName & ' /config ' & $InstallerTempFolder & 'Office' & $OfficeVer & '\ProPlus.WW\config.xml')
        RunWait($InstallerTempFolder & 'Office' & $OfficeVer & '\' & $OfficeFileName & ' /config ' & $InstallerTempFolder & 'Office' & $OfficeVer & '\ProPlus.WW\config.xml')
    Else
        _WriteLogFile($LogFileOpen, 'Source file not found at: ' & $InstallSource & 'Office' & $OfficeVer & '\' & $OfficeFileName
    EndIf
    
    ProgressSet(75)

    While ProcessExists('officesp2.exe')
        Sleep(500)
    WEnd
    
    ProgressSet(100)
    
    ;Cleanup
    FileDelete($TempFolder & $OfficeVer)
    ProgressOff()
    
    ;Debug
    If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'Exiting _InstallOffice Function')
EndFunc   ;==>_InstallOffice

Func _CopyDomainTools($flag)
    ;Debug
    If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'Entering _CopyDomainTools Function')

    Local $Sourcecheck = FileExists($InstallSource & $DomainToolsFolderName & '\' & $DomainToolsFileName)
    
    If $Sourcecheck == 1 Then
        DirCopy($InstallSource & $DomainToolsFolderName, $TempFolder & '\' & $DomainToolsFolderName, 1)
        ShellExecute($TempFolder & $DomainToolsFolderName)
    Else
        _WriteLogFile($LogFileOpen, 'Source file not found at: ' & $InstallSource & $DomainToolsFolderName & '\' & $DomainToolsFileName)
    EndIf
    ;Debug
    If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'Exiting _CopyDomainTools Function')
EndFunc   ;==>_CopyDomainTools

Func _InstalliTunes($Flag)
    ;Debug
    If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'Entering _InstalliTunes Function')
        
    ;Copy files to temp folder
    Local $Sourcecheck1 = FileExists($InstallSource & $QuickTimeFileName)
    Local $Sourcecheck2 = FileExists($InstallSource & $iTunesFileName)
    Local $Sourcecheck3 = FileExists($InstallSource & $AppleAppSupportFileName)
    Local $Sourcecheck4 = FileExists($InstallSource & $SoftwareUpdateFileName)
    Local $Sourcecheck5 = FileExists($InstallSource & $BonjourFileName)
    
    ;Install the different programs
    ProgressOn('iTunes', 'Installing')
    ProgressSet(20)
    If $Sourcecheck1 == 1 Then
        FileCopy($InstallSource & $QuickTimeFileName, $TempFolder, 1)
        _WriteLogFile($LogFileOpen, 'Running Command: msiexec /i ' & $TempFolder & $QuickTimeFileName & ' /qn')
        RunWait("msiexec /i" & $TempFolder & $QuickTimeFileName & ' /qn')
    Else
        MsgBox(0, 'File not found', 'Source file not found at: ' & $InstallSource & $QuickTimeFileName)
    EndIf
        
    ProgressSet(30)
    If $Sourcecheck2 == 1 Then
        FileCopy($InstallSource & $iTunesFilename, $TempFolder, 1)
        _WriteLogFile($LogFileOpen, 'Running Command: msiexec /i ' & $TempFolder & $iTunesFileName & ' /qn')
        RunWait("msiexec /i" & $TempFolder & $iTunesFileName & ' /qn')
    Else
        MsgBox(0, 'File not found', 'Source file not found at: ' & $InstallSource & $iTunesFileName)
    EndIf
    
    ProgressSet(50)
    If $Sourcecheck3 == 1 Then
        FileCopy($InstallSource & $AppleAppSupportFileName, $TempFolder, 1)
        _WriteLogFile($LogFileOpen, 'Running Command: msiexec /i ' & $TempFolder & $AppleAppSupportFileName & ' /qn')
        RunWait("msiexec /i" & $TempFolder & $AppleAppSupportFileName & ' /qn')
    Else
        MsgBox(0, 'File not found', 'Source file not found at: ' & $InstallSource & $AppleAppSupportFileName)
    EndIf   
    
    ProgressSet(80)
    If $Sourcecheck4 == 1 Then
        FileCopy($InstallSource & $SoftwareUpdateFileName, $TempFolder, 1)
        _WriteLogFile($LogFileOpen, 'Running Command: msiexec /i ' & $TempFolder & $SoftwareUpdateFileName & ' /qn')
        RunWait("msiexec /i" & $TempFolder & $SoftwareUpdateFileName & ' /qn')
    Else
        MsgBox(0, 'File not found', 'Source file not found at: ' & $InstallSource & $SoftwareUpdateFileName)
    EndIf
    
    ProgressSet(90)
    If $Sourcecheck5 == 1 Then
        FileCopy($InstallSource & $BonjourFileName, $TempFolder, 1)
        _WriteLogFile($LogFileOpen, 'Running Command: msiexec /i ' & $TempFolder & $BonjourFileName & ' /qn')
        RunWait("msiexec /i" & $TempFolder & $BonjourFileName & ' /qn')
    Else
        MsgBox(0, 'File not found', 'Source file not found at: ' & $InstallSource & $BonjourFileName)
    EndIf
    ProgressSet(100)
    
    ;Cleanup
    FileDelete($TempFolder & $QuickTimeFileName)
    FileDelete($TempFolder & $iTunesFileName)
    FileDelete($TempFolder & $AppleAppSupportFileName)
    FileDelete($TempFolder & $SoftwareUpdateFileName)
    FileDelete($TempFolder & $BonjourFileName)
    ProgressOff()

    ;Debug
    If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'Exiting _InstalliTunes Function')
EndFunc

Func _InstallVLC($flag)
    ;Debug
    If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'Entering _InstallVLC Function')
    
    Local $Sourcecheck = FileExists($InstallSource & $VLCFileName)
    ProgressOn('VLC','Installing')
    If FileExists(@ProgramFilesDir & '\VideoLAN\VLC\uninstall.exe') Then
        ProgressSet(25)
        ;Debug
        If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'Running Command: ' & @ProgramFilesDir & '\VideoLAN\VLC\uninstall.exe /S')
        RunWait(@ProgramFilesDir & '\VideoLAN\VLC\uninstall.exe /S')
        FileDelete(@ProgramFilesDir & '\VideoLAN')
    EndIf
     
    If $Sourcecheck == 1 Then
        ProgressSet(50, '')
        FileCopy($InstallSource & $VLCFileName, $TempFolder, 1)
        ;Debug
        If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'Running command: ' & $TempFolder & $VLCFileName & ' /S /language=en_GB')
        RunWait($TempFolder & $VLCFileName & ' /S /language=en_GB')
        ProgressSet(90)
    Else
        _WriteLogFile($LogFileOpen, 'Source file not found at: ' & $InstallSource & $VLCFilename)
    EndIf
    ProgressSet(100)
    
    ;Cleanup
    FileDelete($TempFolder & $VLCFileName)
    ProgressOff()
    
    ;Debug
    If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'Exiting _InstallVLC Function')
EndFunc   ;==>_InstallVLC

Func _InstallTrendMicro($flag)
    ;Debug
    If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'Entering _InstallTrendMicro Function')
        
    Local $Sourcecheck = FileExists($TrendMicroPath & '\' & $TrendMicroFileName)
    If $Sourcecheck == 1 Then
        FileCopy($InstallSource & $TrendMicroFileName, $TempFolder, 1)
        ;Debug
        If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'Running command: ' & 'msiexec /i ' & $TempFolder & $MobileMeFileName & ' /passive /norestart')
        RunWait('msiexec /i ' & $TempFolder & $MobileMeFileName & ' /passive /norestart')
    Else
        _WriteLogFile($LogFileOpen, 'Source file not found at: ' & $InstallSource & $TrendMicroFilename)
    EndIf
    ;Debug
    If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'Exiting _InstallTrendMicro Function')
EndFunc   ;==>_InstallTrendMicro

Func _WriteLogFile($sLogPath, $sLogMsg)
    ;==============================================
    ; Local Constant/Variable Declaration Section
    ;==============================================
    Local $sDateNow
    Local $sTimeNow
    Local $sMsg
    Local $hOpenFile
    Local $hWriteFile

    $sDateNow = @YEAR & "-" & @MON & "-" & @MDAY
    $sTimeNow = @HOUR & ":" & @MIN & ":" & @SEC
    $sMsg = $sDateNow & " " & $sTimeNow & " : " & $sLogMsg

    $hWriteFile = FileWriteLine($sLogPath, $sMsg)

    If $hWriteFile = -1 Then
        SetError(2)
        Return 0
    EndIf
EndFunc   ;==>_WriteLogFile

Func _SelectAll()
    For $i = 0 To UBound($DeskCtrl) - 1
        GUICtrlSetState($DeskCtrl[$i], $GUI_CHECKED)
    Next
EndFunc   ;==>_SelectAll

Func _DeselectAll()
    For $i = 0 To UBound($DeskCtrl) - 1
        GUICtrlSetState($DeskCtrl[$i], $GUI_UNCHECKED)
    Next
EndFunc   ;==>_DeselectAll

Func SpecialEvents()
    Select
        Case @GUI_CtrlId = $GUI_EVENT_CLOSE
            Exit
    EndSelect

EndFunc   ;==>SpecialEvents

Func Exitier()
    DirRemove('C:\Temp\Xskin', 1)
    DirRemove($TempFolder_Icons, 1)
    Exit
EndFunc   ;==>Exitier

Share this post


Link to post
Share on other sites



...disclaimer and original author information intact.

Fixed.


[sub]My UDF[/sub][sub] - Basics and Time extensions. Great for those new at AutoIt, also contains some powerful time extensions for pros.[/sub][sub]ScrabbleIt[/sub][sub] - Scrabble done in pure AutoIt. (In Progress)[/sub][sub]Nerd Party Extreme | My Portfolio | [email="fett8802@gmail.com"]Contact Me[/email][/sub]

Share this post


Link to post
Share on other sites

Fixed.

lol, thx, i'm an idiot

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