Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Cannot lock preferences

  • 9 svar
  • 1 har dette problemet
  • 4 views
  • Siste svar av Tanyac

more options

I'm trying to lock down a laptop which gets used by several people and they keep changing the firefox settings.

I have Firefox 50.1.0 installed

I have created the local-prefs.js file with these two lines

pref("general.config.obscure_value", 0); 
pref("general.config.filename", "mozilla.cfg");

I have placed this file in defaults/pref subfolder of the installation directory.

If I try to load Firefox with these lines it complains it cannot load the configuration file. If I remove the first line there are no error messages and Firefox loads successfully.

I have created a mozilla.cfg file and placed it in the program folder C:\Program Files\Mozilla Firefox.

According to the UA string I am using Firefox x64: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:50.0) Gecko/20100101 Firefox/50.0

I had a lot of entries in the mozilla.cfg file but in trying to get it to work I've now cut it down to one entry and it still will not work.

// lockpref("media.peerconnection.enabled",false);

This value still shows User Set and if I set it to True it stays at True.

I also tried just this line...

lockpref("browser.startup.homepage","data:text/plain,browser.startup.homepage=http://server/home");

I originally had it's value set to lockpref("browser.startup.homepage","http://server/home");

But when trying to resolve this issue one of the results from my searching said that it has to be the first format listed above. Neither one works.

What am I doing wrong?

I'm trying to lock down a laptop which gets used by several people and they keep changing the firefox settings. I have Firefox 50.1.0 installed I have created the local-prefs.js file with these two lines pref("general.config.obscure_value", 0); pref("general.config.filename", "mozilla.cfg"); I have placed this file in defaults/pref subfolder of the installation directory. If I try to load Firefox with these lines it complains it cannot load the configuration file. If I remove the first line there are no error messages and Firefox loads successfully. I have created a mozilla.cfg file and placed it in the program folder C:\Program Files\Mozilla Firefox. According to the UA string I am using Firefox x64: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:50.0) Gecko/20100101 Firefox/50.0 I had a lot of entries in the mozilla.cfg file but in trying to get it to work I've now cut it down to one entry and it still will not work. // lockpref("media.peerconnection.enabled",false); This value still shows User Set and if I set it to True it stays at True. I also tried just this line... lockpref("browser.startup.homepage","data:text/plain,browser.startup.homepage=http://server/home"); I originally had it's value set to lockpref("browser.startup.homepage","http://server/home"); But when trying to resolve this issue one of the results from my searching said that it has to be the first format listed above. Neither one works. What am I doing wrong?

All Replies (9)

more options

Try to add a comment line at the start of the local-settings.js file as well in case the first line is skipped. Some have reported that this is necessary.

//
pref("general.config.filename", "mozilla.cfg");
pref("general.config.obscure_value", 0);

These functions can be used in the mozilla.cfg file:

defaultPref();	// set new default value
pref();		// set pref, allow changes in current session
lockPref();	// lock pref, disallow changes

The mozilla.cfg and local-settings.js files need to start with a comment line (//).

Endret av cor-el

more options

...and it's lockPref with a capitalised "P" as cor-el already mentioned.

more options

Sorry guys. I was a little sloppy with my post.

In Both of the files the // is the first line All of the directives were exactly lockPref and all ended with a ;

I went through the files so many times checking for punctuation and grammar and then went and posted here without the same diligence. Sorry for that.

Excluding the // which must be the first line, is the order of the directives important, because in my local-prefs.js file, I have

// pref("general.config.obscure_value", 0); pref("general.config.filename", "mozilla.cfg");

Where as cor-el has stipulated

// pref("general.config.filename", "mozilla.cfg"); pref("general.config.obscure_value", 0);

EDIT: Ok, I've tested it on my pc, and it doesn't matter what order I specify those two lines, if I have the obscure directive in the file it responds "Failed to read configuration file"

The local-prefs.js is definitely in the defaults/prefs folder with the channel-prefs.js file (FF is seeing it and racting to it). The mozilla.cfg is definitely in the same folder as firefox.exe (c:\Program Files\Mozilla Firefox)

Endret av Tanyac

more options

Did you verify that the mozilla.cfg is a .cfg file and didn't accidentally got a hidden .txt file extension?

A "Failed to read configuration file" error means that Firefox doesn't find the mozilla.cfg or that the file is corrupted. You can test this latter with an empty mozilla.cfg file.

more options

cor-el said

Did you verify that the mozilla.cfg is a .cfg file and didn't accidentally got a hidden .txt file extension?

Yes. I show file extensions and it is definitely just .cfg

A "Failed to read configuration file" error means that Firefox doesn't find the mozilla.cfg or that the file is corrupted. You can test this latter with an empty mozilla.cfg file.

Indeed. Anything more than // in the file results in the failed read.

more options

Is mozilla.cfg a plain text file?

Does this file work if you save it from a Firefox tab as mozilla.cfg ad place it in the main Firefox program folder?

  • data:text/plain;charset=utf-8;base64,Ly8KbG9ja1ByZWYoIm1lZGlhLnBlZXJjb25uZWN0aW9uLmVuYWJsZWQiLGZhbHNlKTsK
more options

OMG! Found it (Well, my son did). Seems my eyesight isn't what it used to be (And I'm on a 2540x1440p monitor).. I had a : instead of a ; at the end of a line.

Now, having fixed that, I find that it still does not seem to achieve what I want. I have these lines...

lockPref("browser.search.defaultenginename","DuckDuckGo"); lockPref("browser.search.order.1","DuckDuckGo"); lockPref("browser.search.order.2","Google"); lockPref("browser.search.order.3","Wikipedia"); lockPref("browser.search.showOneOffButtons",false);

The settings in the browser still show as Google. about:config now shows these as the above values, and says they are locked, but I can change the default search engine, I can select/unselect any of the one offs.

Almost there :)

more options

I think that support for setting the search engine via prefs has been dropped to prevent misuse, just like has been done with the new tab setting.

The setting of the current default search engine is stored in search.json.mozlz4 (previously in search-metadata.json) in the Firefox profile folder under the [global] section. Browser Console:

var searchService = Services.search;
var currentEngine = searchService.currentEngine.name;
var engine = searchService.getEngineByName("Google");
searchService.currentEngine = engine; //set current engine to Google

  • Bug 1029148 - store "current search engine" configuration outside of prefs (34+)
more options

cor-el said

I think that support for setting the search engine via prefs has been dropped to prevent misuse, just like has been done with the new tab setting.

Meaning what? That one cannot lock down the search engine anymore? Well, that sucks big time.

There doesn't seem to be an extension for this like there is for the newtab issue.

Is there any way to change the contents of that file?

May be I should be looking for a Windows tool that restores not just firefox settings, but other windows settings that people change. Problem with that is that these typically only happen at log on so they can still change settings.

Endret av Tanyac