AutoIt3 and FF.au3 - “error reading registry entry for FireFox” 2017 March


AutoIt3 and FF.au3 is striking again with the “error reading registry entry for FireFox”.
On one of my 32 bit computer the registry key CurrentVersion under  KEY_LOCAL_MACHINE\SOFTWARE\\Mozilla\Mozilla Firefox does not exists. 
Therefore I got the following error when I run the script on this particular computer:
__FFStartProcess ==> General Error: Error reading registry entry for FireFox.
HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox\*CurrentVersion*\Main\PathToExe


How to fix?
By replacing the regread function with RegEnumKey function in the __FFStartProcess function. The fixes is highlighted below. 

Note: I made an improvement in how to declare $sHKLM variable.

 ======Before Update

Local $sHKLM = 'HKEY_LOCAL_MACHINE\SOFTWARE\'
If @OSArch <> 'X86' Then $sHKLM &= 'Wow6432Node\'
$sHKLM &= 'Mozilla\Mozilla Firefox'
Local $sFFExe = RegRead($sHKLM & "" & RegRead($sHKLM, "CurrentVersion") & "\Main", "PathToExe")
If @error Then
    SetError(__FFError($sFuncName, $_FF_ERROR_GeneralError, "Error reading registry entry for FireFox." & @CRLF & _
            $sHKLM & "\*CurrentVersion*\Main\PathToExe" & @CRLF & _
            "Error from RegRead: " & @error))
    Return 0
EndIf

====== After Update

Local $sHKLM = 'HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mozilla\Mozilla Firefox\'

If @OSArch = 'X86' Then $sHKLM = stringreplace($sHKLM, "Wow6432Node\", "")
$sHKLM &=  Regenumkey($sHKLM ,1) & "\Main"
If @error Then
    SetError(___firefox_Error($sFuncName, $__firefox__ERROR_GeneralError, "Error reading registry entry for FireFox." & @CRLF & _
    $sHKLM&"\*CurrentVersion*\Main\PathToExe" & @CRLF & _
    "Error from RegRead: " & @error))
    Return 0
EndIf

No comments:

Post a Comment