Jump to content

Change Firefox auto update


Recommended Posts

Hi,

After searching online for a way to enable auto update for Firefox I came across this code for disabling auto update. I just want to get rid of any message boxes a user might see. Not quite sure how $Message relates to MsgBox. I am assuming they don't relate to one another, but I don't know AutoIT. I just want to reverse engineer this so that auto update is on and no message boxes are displayed to the user.

; This program will set firefox to not auto-update itself

$debug=False

; wait for Firefox to close because the prefs.js will be overwritten when Firefox closes and the changes we make will be lost
ProcessWaitClose("firefox.exe")

If FileExists( @AppDataDir & "\Mozilla\Firefox\profiles.ini" ) Then
	$var = IniRead(@AppDataDir & "\Mozilla\Firefox\profiles.ini", "Profile0", "Path", "NotFound")
Else
	Exit
EndIf

; replace the / in the Path with a backslash
$var = StringReplace($var,"/","\")
$preffile = @AppDataDir & "\Mozilla\Firefox\" & $var & "\prefs.js"

; if the file exists then open it
if FileExists( $preffile ) Then
	$fh = FileOpen( $preffile, 0 )
	$message = FileRead( $fh )
	FileClose( $fh )
	; if the string doesn't exist we need to add it otherwise we make sure it is set to false
	If StringInStr( $message, "app.update.enabled" ) Then
		; check to see if it is already false... if so just Exit
		If StringInStr( $message, "user_pref(""app.update.enabled"", true);" ) Then
			$message = StringReplace( $message, "user_pref(""app.update.enabled"", true)", "user_pref(""app.update.enabled"", false)")
			$update=True
		Else
			; it is already false so just Exit
			Exit
		EndIf
	Else
		$message = StringReplace( $message, " */" & @CRLF & @CRLF,  " */" & @CRLF & @CRLF & "user_pref(""app.update.enabled"", false);" & @CRLF )
		$update=True
	EndIf
Else
	Exit
	; $message = "Prefs file does not exist."
EndIf

If $debug Then MsgBox(4096, "Result", $message)
	
If $update Then
	; we need to update the file
	$fh = FileOpen($preffile, 2)
	; Check if file opened for writing OK
	If $fh = -1 Then
		MsgBox(0, "Error", "Unable to open file.")
		Exit
	EndIf
	FileWrite($fh, $message)
	FileClose($fh)
EndIf


Thanks.

Link to comment
Share on other sites

If you set

$debug = True

then you will see the Msgbox show at this line

If $debug Then MsgBox(4096, "Result", $message)

with the value of $message in it. $message contains the read contents of

@AppDataDir & "\Mozilla\Firefox\" & $var & "\prefs.js"

that has been modified by the String* functions.

If you want no MsgBoxes then try this that has minor changes made.

; wait for Firefox to close because the prefs.js will be overwritten when Firefox closes and the changes we make will be lost
ProcessWaitClose("firefox.exe")

If FileExists( @AppDataDir & "\Mozilla\Firefox\profiles.ini" ) Then
    $var = IniRead(@AppDataDir & "\Mozilla\Firefox\profiles.ini", "Profile0", "Path", "NotFound")
Else
    Exit 1
EndIf

; replace the / in the Path with a backslash
$var = StringReplace($var,"/","\")
$preffile = @AppDataDir & "\Mozilla\Firefox\" & $var & "\prefs.js"

; if the file exists then open it
if FileExists( $preffile ) Then
    $fh = FileOpen( $preffile, 0 ) ; read
    If $fh = -1 Then Exit 2
    $message = FileRead( $fh )
    FileClose( $fh )
    ; if the string doesn't exist we need to add it otherwise we make sure it is set to false
    If StringInStr( $message, "app.update.enabled" ) Then
        ; check to see if it is already false... if so just Exit
        If StringInStr( $message, "user_pref(""app.update.enabled"", true);" ) Then
            $message = StringReplace( $message, "user_pref(""app.update.enabled"", true)", "user_pref(""app.update.enabled"", false)")
            $update = True
        Else
            ; it is already false so just Exit
            Exit
        EndIf
    Else
        $message = StringReplace( $message, " */" & @CRLF & @CRLF,  " */" & @CRLF & @CRLF & "user_pref(""app.update.enabled"", false);" & @CRLF )
        $update = True
    EndIf
Else
    Exit 3
    ; $message = "Prefs file does not exist."
EndIf
    
If $update Then
    ; we need to update the file
    $fh = FileOpen($preffile, 2) ; erase
    ; Check if file opened for writing OK
    If $fh = -1 Then Exit 4
    FileWrite($fh, $message)
    FileClose($fh)
EndIf

:)

Link to comment
Share on other sites

Hi,

Thanks. Do I have this right for the purposes of checking to see if its false and then setting it to true?

; if the string doesn't exist we need to add it otherwise we make sure it is set to true
	If StringInStr( $message, "app.update.enabled" ) Then
		; check to see if it is already true... if so just Exit
		If StringInStr( $message, "user_pref(""app.update.enabled"", false);" ) Then
			$message = StringReplace( $message, "user_pref(""app.update.enabled"", false)", "user_pref(""app.update.enabled"", true)")
			$update=True
		Else
			; it is already true so just Exit
			Exit
		EndIf
	Else
		$message = StringReplace( $message, " */" & @CRLF & @CRLF,  " */" & @CRLF & @CRLF & "user_pref(""app.update.enabled"", true);" & @CRLF )
		$update=True

I am not sure I followed the code correctly to change it where it needed to be changed.

Edited by Briandr
Link to comment
Share on other sites

  • 2 weeks later...

Hi,

I know Google Chrome will auto update itself whenever a new version is released, but in the event a user disables it is there any spin I could put on the above script for enabling auto update for Firefox so that it works in the same manner as Google Chrome?

Thanks.

Link to comment
Share on other sites

Hi,

I know Google Chrome will auto update itself whenever a new version is released, but in the event a user disables it is there any spin I could put on the above script for enabling auto update for Firefox so that it works in the same manner as Google Chrome?

Thanks.

The 2 browsers use completely different methods for turning on/off Auto Update. See this link to see how to enable/disable it in Chrome.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Hi,

Thanks for responding. I was hoping there might be a config file (like Firefox has) that controls the settings as opposed to a registry setting. Not sure if a reboot would be required. With the registry usually a reboot is required. It looks like this would have to be scripted out from sratch. I was hoping to avoid a re-write.

Link to comment
Share on other sites

I don't want Firefox updates turned off. If you read further up in this thread someone on the boards provided me a script that will turn them on, in the event they are off. Read MHz's reply and then further up you will see my original question.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...