#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include-once ; #INDEX# ======================================================================================================================= ; Title .........: NavInfo v.1.2.0 ; AutoIt Version : v3.3.8.1 ; Description ...: Check if the most common browser are installed and retrive usefull information. ; Author(s) .....: Nessie ; =============================================================================================================================== ; #INCLUDES# ========================================================================================================= ; None ; #GLOBAL VARIABLES# ================================================================================================= ; None ; #INTERNAL_USE_ONLY# =========================================================================================================== ; __NavInfo__NavInfo_PathSanitize( ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ;_NavInfo_GetDefaultBrowser ;_NavInfo_GetIEVersion ;_NavInfo_IsFirefoxInstalled ;_NavInfo_GetFirefoxVersion ;_NavInfo_GetFirefoxLocation ;_NavInfo_IsThunderbirdInstalled ;_NavInfo_GetThunderbirdVersion ;_NavInfo_GetThunderbirdLocation ;_NavInfo_IsChromeInstalled ;_NavInfo_GetChromeVersion ;_NavInfo_GetChromeLocation ;_NavInfo_IsOperaInstalled ;_NavInfo_GetOperaVersion ;_NavInfo_GetOperaLocation ;_NavInfo_IsSafariInstalled ;_NavInfo_GetSafariVersion ;_NavInfo_GetSafariLocation ;_NavInfo_IsJavaInstalled ;_NavInfo_GetJavaVersion ;_NavInfo_GetJavaLocation ;_NavInfo_IsSilverlightInstalled ;_NavInfo_GetSilverlightVersion ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name...........: _NavInfo_GetDefaultBrowser ; Description ...: Detect the default browser ; Syntax.........: _NavInfo_GetDefaultBrowser() ; Return values .: On Success - Return the file name of the default browser ex ; On Failure - Returns "" and sets @error to non-zero ; Author ........: Nessie ; =============================================================================================================================== Func _NavInfo_GetDefaultBrowser() Local $sKey = "HKEY_CURRENT_USER\Software\Classes\http\shell\open\command\" Local $sBrowserExe = RegRead($sKey, "") If @error Then Return SetError(1, 0, "") Local $aResult = StringRegExp($sBrowserExe, '\\((?i)[^\\]*.exe)', 3) If @error Then Return SetError(1, 0, "") Return $aResult[0] EndFunc ;==>_NavInfo_GetDefaultBrowser ; #FUNCTION# ==================================================================================================================== ; Name...........: _NavInfo_GetIEVersion ; Description ...: Get the current Internet Explorer version ; Syntax.........: _NavInfo_GetIEVersion() ; Return values .: On Success - Return the file name of the default browser ex ; On Failure - Returns "" and sets @error to non-zero ; Author ........: Nessie ; =============================================================================================================================== Func _NavInfo_GetIEVersion() Local $sVersion = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer", "Version") If @error Then Return SetError(1, 0, "") Return $sVersion EndFunc ;==>_NavInfo_GetIEVersion ; #FUNCTION# ==================================================================================================================== ; Name...........: _NavInfo_IsFirefoxInstalled ; Description ...: Check if Firefox is installed ; Syntax.........: _NavInfo_IsFirefoxInstalled() ; Return values .: On Success - Return True ; On Failure - Return False ; Author ........: Nessie ; =============================================================================================================================== Func _NavInfo_IsFirefoxInstalled() Return FileExists(_NavInfo_GetFirefoxLocation()) = 1 EndFunc ;==>_NavInfo_IsFirefoxInstalled ; #FUNCTION# ==================================================================================================================== ; Name...........: _NavInfo_GetFirefoxVersion ; Description ...: Get the current Firefox version ; Syntax.........: _NavInfo_GetFirefoxVersion() ; Return values .: On Success - Return an array with this info ; $array[0] = Firefox version ; $array[1] = Firefox Language ; On Failure - ; @error = 1 Firefox not installed ; @error = 2 Unable to retrive the version ; Author ........: Nessie ; =============================================================================================================================== Func _NavInfo_GetFirefoxVersion() Local $sKey If @OSArch = 'X64' Then $sKey = "HKEY_LOCAL_MACHINE64\SOFTWARE\Wow6432Node\Mozilla\Mozilla Firefox" Else $sKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox" EndIf Local $sCurrentVersion = RegRead($sKey, "CurrentVersion") If @error Then Return SetError(1, 0, "") Local $aRegex = StringRegExp($sCurrentVersion, "(.*?)\((.*?)\)", 3) If @error Then Return SetError(2, 0, -1) Return $aRegex EndFunc ;==>_NavInfo_GetFirefoxVersion ; #FUNCTION# ==================================================================================================================== ; Name...........: _NavInfo_GetFirefoxLocation ; Description ...: Retrive the Firefox installation path ; Syntax.........: _NavInfo_GetFirefoxLocation() ; Return values .: On Success - Return the firefox location ; On Failure - Returns "" and sets @error to non-zero ; Author ........: Nessie ; =============================================================================================================================== Func _NavInfo_GetFirefoxLocation() Local $sKey If @OSArch = 'X64' Then $sKey = "HKEY_LOCAL_MACHINE64\SOFTWARE\Wow6432Node\Mozilla\Mozilla Firefox" Else $sKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox" EndIf Local $sCurrentVersion = RegRead($sKey, "CurrentVersion") If @error Then Return SetError(1, 0, "") Local $sPathToExe = RegRead($sKey & "\" & $sCurrentVersion & "\Main", "PathToExe") If @error Then Return SetError(1, 0, "") Return $sPathToExe EndFunc ;==>_NavInfo_GetFirefoxLocation ; #FUNCTION# ==================================================================================================================== ; Name...........: _NavInfo_IsThunderbirdInstalled ; Description ...: Check if Thunderbird is installed ; Syntax.........: _NavInfo_IsThunderbirdInstalled() ; Return values .: On Success - Return True ; On Failure - Return False ; Author ........: Nessie ; =============================================================================================================================== Func _NavInfo_IsThunderbirdInstalled() Return FileExists(_NavInfo_GetThunderbirdLocation()) = 1 EndFunc ;==>_NavInfo_IsThunderbirdInstalled ; #FUNCTION# ==================================================================================================================== ; Name...........: _NavInfo_GetThunderbirdVersion ; Description ...: Get the current Thunderbird version ; Syntax.........: _NavInfo_GetThunderbirdVersion() ; Return values .: On Success - Return an array with this info ; $array[0] = Thunderbird version ; $array[1] = Thunderbird Language ; On Failure - ; @error = 1 Thunderbird not installed ; @error = 2 Unable to retrive the version ; Author ........: Nessie ; =============================================================================================================================== Func _NavInfo_GetThunderbirdVersion() Local $sKey If @OSArch = 'X64' Then $sKey = "HKEY_LOCAL_MACHINE64\SOFTWARE\Wow6432Node\Mozilla\Mozilla Thunderbird" Else $sKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Thunderbird" EndIf Local $sCurrentVersion = RegRead($sKey, "CurrentVersion") If @error Then Return SetError(1, 0, "") Local $aRegex = StringRegExp($sCurrentVersion, "(.*?)\((.*?)\)", 3) If @error Then Return SetError(2, 0, -1) Return $aRegex EndFunc ;==>_NavInfo_GetThunderbirdVersion ; #FUNCTION# ==================================================================================================================== ; Name...........: _NavInfo_GetThunderbirdLocation ; Description ...: Retrive the Thunderbird installation path ; Syntax.........: _NavInfo_GetThunderbirdLocation() ; Return values .: On Success - Return the Thunderbird location ; On Failure - Returns "" and sets @error to non-zero ; Author ........: Nessie ; =============================================================================================================================== Func _NavInfo_GetThunderbirdLocation() Local $sKey If @OSArch = 'X64' Then $sKey = "HKEY_LOCAL_MACHINE64\SOFTWARE\Wow6432Node\Mozilla\Mozilla Thunderbird" Else $sKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Thunderbird" EndIf Local $sCurrentVersion = RegRead($sKey, "CurrentVersion") If @error Then Return SetError(1, 0, "") Local $sPathToExe = RegRead($sKey & "\" & $sCurrentVersion & "\Main", "PathToExe") If @error Then Return SetError(1, 0, "") Return $sPathToExe EndFunc ;==>_NavInfo_GetThunderbirdLocation ; #FUNCTION# ==================================================================================================================== ; Name...........: _NavInfo_IsChromeInstalled ; Description ...: Check if Chrome is installed ; Syntax.........: _NavInfo_IsChromeInstalled() ; Return values .: On Success - Return True ; On Failure - Return False ; Author ........: Nessie ; =============================================================================================================================== Func _NavInfo_IsChromeInstalled() Return FileExists(_NavInfo_GetChromeLocation()) = 1 EndFunc ;==>_NavInfo_IsChromeInstalled ; #FUNCTION# ==================================================================================================================== ; Name...........: _NavInfo_GetChromeVersion ; Description ...: Get the current Chrome version ; Syntax.........: _NavInfo_GetChromeVersion() ; Return values .: On Success - Return the Chrome version ; On Failure - Returns "" and sets @error to non-zero ; Author ........: Nessie ; =============================================================================================================================== Func _NavInfo_GetChromeVersion() Local $sKey[2], $sPath, $sVersion If @OSArch = 'X64' Then $sKey[0] = "HKEY_LOCAL_MACHINE64\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe" $sKey[1] = "HKEY_LOCAL_MACHINE64\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\App\chrome.exe" ;For old chrome x32 installed on x64 system Else $sKey[0] = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe" ReDim $sKey[1] EndIf For $i = 0 To UBound($sKey) - 1 $sPath = RegRead($sKey[$i], "") If @error Then ContinueLoop If Not FileExists($sPath) Then ContinueLoop $sVersion = FileGetVersion($sPath) If @error Then ContinueLoop Return $sVersion Next Return SetError(1, 0, "") EndFunc ;==>_NavInfo_GetChromeVersion ; #FUNCTION# ==================================================================================================================== ; Name...........: _NavInfo_GetChromeLocation ; Description ...: Retrive the Chrome installation path ; Syntax.........: _NavInfo_GetChromeLocation() ; Return values .: On Success - Return the Chrome location ; On Failure - Returns "" and sets @error to non-zero ; Author ........: Nessie ; =============================================================================================================================== Func _NavInfo_GetChromeLocation() Local $sKey[2], $sPath If @OSArch = 'X64' Then $sKey[0] = "HKEY_LOCAL_MACHINE64\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe" $sKey[1] = "HKEY_LOCAL_MACHINE64\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\App\chrome.exe" ;For old chrome x32 installed on x64 system Else $sKey[0] = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe" ReDim $sKey[1] EndIf For $i = 0 To UBound($sKey) - 1 $sPath = RegRead($sKey[$i], "") If @error Then ContinueLoop If Not FileExists($sPath) Then ContinueLoop Return $sPath Next Return SetError(1, 0, "") EndFunc ;==>_NavInfo_GetChromeLocation ; #FUNCTION# ==================================================================================================================== ; Name...........: _NavInfo_IsOperaInstalled ; Description ...: Check if Opera is installed ; Syntax.........: _NavInfo_IsOperaInstalled() ; Return values .: On Success - Return True ; On Failure - Return False ; Author ........: Nessie ; =============================================================================================================================== Func _NavInfo_IsOperaInstalled() Return FileExists(_NavInfo_GetOperaLocation()) = 1 EndFunc ;==>_NavInfo_IsOperaInstalled ; #FUNCTION# ==================================================================================================================== ; Name...........: _NavInfo_GetOperaVersion ; Description ...: Get the current Opera version ; Syntax.........: _NavInfo_GetOperaVersion() ; Return values .: On Success - Return the Opera version ; On Failure - Returns "" and sets @error to non-zero ; Author ........: Nessie ; =============================================================================================================================== Func _NavInfo_GetOperaVersion() Local $sVersion = FileGetVersion(_NavInfo_GetOperaLocation()) If @error Then Return SetError(1, 0, "") Return $sVersion EndFunc ;==>_NavInfo_GetOperaVersion ; #FUNCTION# ==================================================================================================================== ; Name...........: _NavInfo_GetOperaLocation ; Description ...: Retrive the Opera installation path ; Syntax.........: _NavInfo_GetOperaLocation() ; Return values .: On Success - Return the Opera location ; On Failure - Returns "" and sets @error to non-zero ; Author ........: Nessie ; =============================================================================================================================== Func _NavInfo_GetOperaLocation() Local $sKey[2], $sValue = "Last Install Path", $sLastPath If @OSArch = 'X64' Then $sKey[0] = "HKEY_CURRENT_USER64\SOFTWARE\Wow6432Node\Opera Software" ;For x32 Opera.exe installed on x64 system $sKey[1] = "HKEY_CURRENT_USER64\Software\Opera Software" Else $sKey[0] = "HKEY_CURRENT_USER\Software\Opera Software" ReDim $sKey[1] EndIf For $i = 0 To UBound($sKey) - 1 If @OSArch = 'X64' And $i = 1 Then $sValue = "Last Install Path x64" ;Thanks to guinness for tell me this value $sLastPath = RegRead($sKey[$i], $sValue) If @error Then ContinueLoop $sLastPath = __NavInfo_PathSanitize($sLastPath) If Not FileExists($sLastPath & "\opera.exe") Then ContinueLoop Return $sLastPath & "\opera.exe" Next Return SetError(1, 0, "") EndFunc ;==>_NavInfo_GetOperaLocation ; #FUNCTION# ==================================================================================================================== ; Name...........: _NavInfo_IsSafariInstalled ; Description ...: Check if Safari is installed ; Syntax.........: _NavInfo_IsSafariInstalled() ; Return values .: On Success - Return True ; On Failure - Return False ; Author ........: Nessie ; =============================================================================================================================== Func _NavInfo_IsSafariInstalled() Return FileExists(_NavInfo_GetSafariLocation()) = 1 EndFunc ;==>_NavInfo_IsSafariInstalled ; #FUNCTION# ==================================================================================================================== ; Name...........: _NavInfo_GetSafariVersion ; Description ...: Get the current Safari version ; Syntax.........: _NavInfo_GetSafariVersion() ; Return values .: On Success - Return the Safari version ; On Failure - Returns "" and sets @error to non-zero ; Author ........: Nessie ; =============================================================================================================================== Func _NavInfo_GetSafariVersion() Local $sKey If @OSArch = 'X64' Then $sKey = "HKEY_LOCAL_MACHINE64\SOFTWARE\Wow6432Node\Apple Computer, Inc.\Safari" Else $sKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Apple Computer, Inc.\Safari" EndIf Local $sVersion = RegRead($sKey, "Version") If @error Then Return SetError(1, 0, "") Return $sVersion EndFunc ;==>_NavInfo_GetSafariVersion ; #FUNCTION# ==================================================================================================================== ; Name...........: _NavInfo_GetSafariLocation ; Description ...: Retrive the Safari installation path ; Syntax.........: _NavInfo_GetSafariLocation() ; Return values .: On Success - Return the Safari location ; On Failure - Returns "" and sets @error to non-zero ; Author ........: Nessie ; =============================================================================================================================== Func _NavInfo_GetSafariLocation() Local $sKey If @OSArch = 'X64' Then $sKey = "HKEY_LOCAL_MACHINE64\SOFTWARE\Wow6432Node\Apple Computer, Inc.\Safari" Else $sKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Apple Computer, Inc.\Safari" EndIf Local $sBrowserExe = RegRead($sKey, "BrowserExe") If @error Then Return SetError(1, 0, "") Return $sBrowserExe EndFunc ;==>_NavInfo_GetSafariLocation ; #FUNCTION# ==================================================================================================================== ; Name...........: _NavInfo_IsJavaInstalled ; Description ...: Check if Java is installed ; Syntax.........: _NavInfo_IsJavaInstalled() ; Return values .: On Success - Return True ; On Failure - Return False ; Author ........: Nessie ; =============================================================================================================================== Func _NavInfo_IsJavaInstalled() Return FileExists(_NavInfo_GetJavaLocation()) = 1 EndFunc ;==>_NavInfo_IsJavaInstalled ; #FUNCTION# ==================================================================================================================== ; Name...........: _NavInfo_GetJavaVersion ; Description ...: Get the current Java version ; Syntax.........: _NavInfo_GetJavaVersion() ; Return values .: On Success - Return the Java version ; On Failure - Returns "" and sets @error to non-zero ; Author ........: Nessie ; =============================================================================================================================== Func _NavInfo_GetJavaVersion() Local $sVersion = FileGetVersion(_NavInfo_GetJavaLocation()) If @error Then Return SetError(1, 0, "") Return $sVersion EndFunc ;==>_NavInfo_GetJavaVersion ; #FUNCTION# ==================================================================================================================== ; Name...........: _NavInfo_GetJavaLocation ; Description ...: Retrive the Java installation path ; Syntax.........: _NavInfo_GetJavaLocation() ; Return values .: On Success - Return the Java location ; On Failure - Returns "" and sets @error to non-zero ; Author ........: Nessie ; =============================================================================================================================== Func _NavInfo_GetJavaLocation() Local $sKey[2], $sCurrentVersion, $sJavaHome If @OSArch = 'X64' Then $sKey[0] = "HKEY_LOCAL_MACHINE64\SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment" $sKey[1] = "HKEY_LOCAL_MACHINE64\SOFTWARE\JavaSoft\Java Runtime Environment" Else $sKey[0] = "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment" ReDim $sKey[1] EndIf For $i = 0 To UBound($sKey) - 1 $sCurrentVersion = RegRead($sKey[$i], "CurrentVersion") If @error Then ContinueLoop $sJavaHome = RegRead($sKey[$i] & "\" & $sCurrentVersion, "JavaHome") If @error Then ContinueLoop $sJavaHome = __NavInfo_PathSanitize($sJavaHome) If Not FileExists($sJavaHome & "\bin\java.exe") Then ContinueLoop Return $sJavaHome & "\bin\java.exe" Next Return SetError(1, 0, "") EndFunc ;==>_NavInfo_GetJavaLocation ; #FUNCTION# ==================================================================================================================== ; Name...........: _NavInfo_IsSilverlightInstalled ; Description ...: Check if Silverlight is installed ; Syntax.........: _NavInfo_IsSilverlightInstalled() ; Return values .: On Success - Return True ; On Failure - Return False ; Author ........: Nessie ; =============================================================================================================================== Func _NavInfo_IsSilverlightInstalled() Local $sKey If @OSArch = 'X64' Then $sKey = "HKEY_LOCAL_MACHINE64\SOFTWARE\Wow6432Node\Microsoft\Silverlight" Else $sKey = "HKEY_LOCAL_MACHINE\Software\Microsoft\Silverlight" EndIf RegRead($sKey, "Version") If @error Then Return False Return True EndFunc ;==>_NavInfo_IsSilverlightInstalled ; #FUNCTION# ==================================================================================================================== ; Name...........: _NavInfo_GetSilverlightVersion ; Description ...: Get the current Silverlight version ; Syntax.........: _NavInfo_GetSilverlightVersion() ; Return values .: On Success - Return the Silverlight version ; On Failure - Returns "" and sets @error to non-zero ; Author ........: Nessie ; =============================================================================================================================== Func _NavInfo_GetSilverlightVersion() Local $sKey If @OSArch = 'X64' Then $sKey = "HKEY_LOCAL_MACHINE64\SOFTWARE\Wow6432Node\Microsoft\Silverlight" Else $sKey = "HKEY_LOCAL_MACHINE\Software\Microsoft\Silverlight" EndIf Local $sVersion = RegRead($sKey, "Version") If @error Then Return SetError(1, 0, "") Return $sVersion EndFunc ;==>_NavInfo_GetSilverlightVersion ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __NavInfo__NavInfo_PathSanitize ; Description ...: Remove the ending backslash from a path. ; Syntax.........: __NavInfo__NavInfo_PathSanitize($sPath) ; Parameters ....: $sPath - The exe path ; Return values .: Return the new path without the ending backslash ; Author ........: Nessie ; Example .......: __NavInfo__NavInfo_PathSanitize("C:\Software\") ; =============================================================================================================================== Func __NavInfo_PathSanitize($sPath) If StringRight($sPath, 1) = "\" Then $sPath = StringTrimRight($sPath, 1) EndIf Return $sPath EndFunc ;==>__NavInfo_PathSanitize