Search code examples
firefoxregistryautoit

Error reading registry entry for Firefox


I have an AutoIt v3 script (copied from the author of FF.au3):

#Include <FF.au3>

_FFStart("http://ff-au3-example.thorsten-willert.de/")

If _FFIsConnected() Then
    Sleep(2000)
    _FFAction("presentationmode", True)
    Sleep(2000)
    _FFOpenURL("http://www.google.com")
    Sleep(2000)
    _FFAction("back")
    _FFAction("presentationmode", False)
    Sleep(2000)
    _FFOpenURL("chrome:bookmarks")
    Sleep(2000)
    _FFAction("alert", "Bye bye ...")
    _FFQuit()
EndIf

Exit

But when I run it, I get an error message:

__FFStartProcess ==> General Error: Error reading registry entry for FireFox.
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mozilla\Mozilla Firefox\*CurrentVersion*\Main\PathToExe
Error from RegRead: 1

I have Firefox and AutoIt v3 installed, I downloaded the FF.au3 UDF to same directory as my script, and I have MozRepl Firefox plugin installed and activated (it's active at the menu->plug-ins, I don't see the "Activate on startup" option). I do have an entry at:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mozilla\Mozilla Firefox\26.0 (pl)\Main

That points to the right destination. Why is there an "Error reading registry entry for FireFox."?


Solution

  • Here is the relevant piece of code from the Firefox library:

    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
    

    It reads the key CurrentVersion (probably of type REG_SZ) from the path HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mozilla\Mozilla Firefox to get the current version of the application. Say for example that this returns the string "27.0".

    Then it looks in HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mozilla\Mozilla Firefox\27.0\Main (based on the string it just found for the current version) for the key PathToExe (REG_SZ also probably). This is the first attempt and if it does not fail it uses this path for the executable.

    If this fails though, it checks the path HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mozilla\Mozilla Firefox\*CurrentVersion*\Main (literally with the asterisks) for the key PathToExe. This fails as well and that's why you are getting the error.

    Check all of the above registry paths for your system. It may be possible that the Firefox library needs to be updated for the later Firefox versions. Try an "as clean as possible" install of Firefox and see if that works. Also try repairing the installation via the setup/deinstaller if that is possible.

    If nothing works and you are left to modifying your own system to get it to work, I will check and ask the author of the Firefox library to update it.