#Region - includes #include #include #include #include #include #include #include #include #include #include #include #include #EndRegion - includes #Region CompilerOptions #AutoIt3Wrapper_UseX64=N #EndRegion CompilerOptions #Region GlobalDeclarations Global $iDebugLogging=1 #EndRegion GlobalDeclarations #Region code _Main() Func _Main() Switch @OSArch Case "X64" Local $bOSArch=True Case "X86" Local $bOSArch=False EndSwitch ; Check to see if Webdriver is latest. Report but do not update Local $bIsWDLatest=_WD_UpdateDriver('msedge',@ScriptDir,$bOSArch,Null) Local $iUpdatecheck=0 Switch @error Case $_WD_ERROR_InvalidValue _DebugLogging("_WD_UpdateDriver returned error: Invalid Value") _ProgramLog("Could not check Webdriver version. Probably no admin access") $iUpdatecheck=1 Case $_WD_ERROR_GeneralError _DebugLogging("_WD_UpdateDriver returned error: General Error") _ProgramLog("Could not check Webdriver version. Probably no admin access") $iUpdatecheck=1 Case $_WD_ERROR_NotFound _DebugLogging("_WD_UpdateDriver returned error: Not Found") _ProgramLog("Could not check Webdriver version. Probably no admin access") $iUpdatecheck=1 Case $_WD_ERROR_FileIssue _DebugLogging("_WD_UpdateDriver returned error: File Issue") _ProgramLog("Could not check Webdriver version. Probably no admin access") $iUpdatecheck=1 Case $_WD_ERROR_UserAbort _DebugLogging("_WD_UpdateDriver returned error: User Abort") _ProgramLog("Could not check Webdriver version. Probably no admin access") $iUpdatecheck=1 Case $_WD_ERROR_NotSupported _DebugLogging("_WD_UpdateDriver returned error: Not Supported") _ProgramLog("Could not check Webdriver version. Probably no admin access") $iUpdatecheck=1 EndSwitch _DebugLogging("$iUpdatecheck = " & $iUpdatecheck) If $iUpdatecheck=0 Then If $bIsWDLatest=False Then _ProgramLog("Webdriver version is current") _DebugLogging("Webdriver version is current") ;MsgBox($MB_TOPMOST,"INFO","Webdriver version is up to date") Else _ProgramLog("Webdriver version is out of date. Updating") _DebugLogging("Webdriver version is out of date. Updating") Local $bIsWDLatestAgain=_WD_UpdateDriver('msedge',@ScriptDir,$bOSArch,True) ;MsgBox($MB_TOPMOST,"DEBUG","$bIsWDLatestAgain = " & $bIsWDLatestAgain) If $bIsWDLatestAgain=True Then _ProgramLog("Webdriver was successfully updated") _DebugLogging("Webdriver was successfully updated") ;MsgBox($MB_TOPMOST,"ERROR","Webdriver update successful") Else _ProgramLog("Webdriver update failed") _DebugLogging("Webdriver update failed") ;MsgBox($MB_TOPMOST,"ERROR","Webdriver update failed" & @CRLF & "Please report this message to IT") EndIf EndIf EndIf Local $bIsUDFLatest=_WD_IsLatestRelease() Switch @error Case $_WD_ERROR_Exception _DebugLogging("_WD_IsLatestRelease returned error: Exception") _ProgramLog("Could not check Webdriver UDF version. Probably no admin access") Case $_WD_ERROR_GeneralError _DebugLogging("_WD_IsLatestRelease returned error: General Error") _ProgramLog("Could not check Webdriver UDF version. Probably no admin access") Case Else _DebugLogging("_WD_IsLatestRelease was successful") _ProgramLog("_WD_IsLatestRelease was successful") EndSwitch EndFunc ;--> _Main Func _DebugLogging($sDebugText) ; =============================================================================================================================== ; Function : _DebugLogging ; Description ; Function to write debug events to a log file, if global variable $iDebugLogging is set to 1 ; Takes values ; Text to write to log file ; Return value ; none ; Author ; psiess ; =============================================================================================================================== $sDebugLogFile=@ScriptDir & "\WebDriverUpdateDebug.log" If $iDebugLogging = 1 Then ; Open the file for writing (append to the end of a file) and store the handle to a variable. Local $hFileOpen = FileOpen($sDebugLogFile, $FO_APPEND) If $hFileOpen = -1 Then MsgBox($MB_TOPMOST, "", "An error occurred while writing the log file" & @CRLF & "Please report this error to IT") EndIf $sCurrentTime=_NowTime(5) $sCurrentDate=_NowDate() ; Write data to the file using the handle returned by FileOpen. FileWrite($hFileOpen, $sCurrentDate & @TAB) FileWrite($hFileOpen, $sCurrentTime & @TAB) FileWrite($hFileOpen, $sDebugText & @CRLF) FileClose($hFileOpen) EndIf EndFunc ;--> _DebugLogging Func _ProgramLog($sLogText) ; =============================================================================================================================== ; Function : _ProgramLog ; Description ; Function to write program events to a log file ; Takes values ; Text to write to log file ; Return value ; none ; Author ; psiess ; =============================================================================================================================== $sLogFile=@ScriptDir & "\WebDriverUpdate.log" ; Open the file for writing (append to the end of a file) and store the handle to a variable. Local $hFileOpen = FileOpen($sLogFile, $FO_APPEND) If $hFileOpen = -1 Then MsgBox($MB_TOPMOST, "", "An error occurred while writing the log file" & @CRLF & "Please report this error to IT") EndIf $sCurrentTime=_NowTime(5) $sCurrentDate=_NowDate() ; Write data to the file using the handle returned by FileOpen. FileWrite($hFileOpen, $sCurrentDate & @TAB) FileWrite($hFileOpen, $sCurrentTime & @TAB) FileWrite($hFileOpen, $sLogText & @CRLF) FileClose($hFileOpen) EndFunc ;--> _ProgramLog #EndRegion code