How to best modfy 800 Thunderbird Prefs.js files?
November 30, 2011 10:32 AM   Subscribe

We are doing a campus wide migration to gmail, and that means I have a few hundred thunderbird users who need their settings changed to point to a new imap server (and change their username to What is the best way to get this done?

They are non technical users, and since I know I am going to be busy with the 5% who manage to still have problems even if the migration goes fine, I'd like to try to automate the settings changes, unfortunately something like Mission Control was not put in place so we can't centrally change settings for users. So right now it looks like it will have to be something that walks a users Doc&Settings folder and changes their thunderbird prefs.js files. I do have access to get GPO and SCCM advertisements that could run the scripts on targeted machines, but getting the script to do the changes is the sticking point (I'm coming from a unix/bash scripting background).

Are there other tools out there that may already do this, or have folks found other ways around this problem?
posted by mrzarquon to Computers & Internet (8 answers total) 1 user marked this as a favorite
I'm installing a copy of Thunderbird to see if something can be scripted easily. Can you provide an example of your existing prefs.js, and what one would look like pointing to the new server? (please change the usersnames and domain names to protect your privacy, and use if it does not look right here on preview).

If you have SCCM, it would be preferable over GPO as you'll be able to track progress. From my experience with FireFox, the prefs.js gets hidden inside of a randomly generated profile folder..which is highly annoying and adds extra steps for the scripting process. Will see if they use the same arcaic obfuscation with TB shortly...
posted by samsara at 11:23 AM on November 30, 2011

I'll be able to grab something in a bit, but yes, thunderbird uses the exact same preferences storage as firefox, so it is a folder nested somewhere, with a random string.

I'd imagine a global find and replace for any addresses with would work (along with to, as those are the settings that are changing (along with username to change to

I'm thinking from the bash side (when I have to write something for the few mac users), it will just be (just pseudo code for now):

for (users in `ls /Users/`)
for (prefs in `find $users/Library/Thunderbird/*.default/prefs.js`)
cp $prefs $prefs.bak
sed -i 's/' $prefs

and so on.

But doing this in the windows world is the difficult part for me right now.
posted by mrzarquon at 11:38 AM on November 30, 2011

It might be something worth doing in powershell (or vbs if PSH isn't distributed widely). From what I'm seeing, it'll also be more tricky than just plopping a fresh prefs.js in place of the existing.

So far, here is a program outline I can think of:

1. Stop ThunderBird if it is running (this may require some coordination with users where they're initiating the script and know not to launch TB until it is finished...possibly via an interactive SCCM push with no mandatory assignment)

2. Find the default profile of the logged in user by parsing %userprofile%\AppData\Roaming\Thunderbird\profile.ini (if windows vista or 7 is your XP it may be under Application Data or Local Settings instead of AppData)

3. Modify the prefs.js in this profile, replacing the existing server strings with the new ones.
posted by samsara at 12:06 PM on November 30, 2011

What is the breakdown of your users by OS type? As they are on Thunderbird I assume that each one has their home directory and mail configuration on their individual workstation? If not then you could do lots of the manipulation on a server after they were logged out.

Seconding powershell but installing that first might be more difficult than editing by hand.

Can you ftp to/from their workstations? If so you could you do write a script to fetch the mail profile to your workstation, make the edits and ftp it back again (getting preferences right will be important) Programmatically you should also be able to detect if Thunderbird is running and kill it off if so.

An alternative is remotely logging in to download and execute a script.
posted by epo at 12:22 PM on November 30, 2011

I'm thinking, if you're comfortable having the users walk through parts of the process (username/password), you could AutoIT the rest. (There is a record macro function in AutoIT that you can compile into an executable...once run it can take care of automating the account creation process by launching TB directly (no need to physically touch prefs.js).

An example snippit of my prefs.js looks like this. (kindof daunting unless these mailboxes are identical in their layout).

So how does that sound? An AutoIT script that is user initiated from a SCCM interactive push (non-mandatory with notification) where they supply their credentials when prompted.

Otherwise you'll need to build a vbs or psh script that will:

1. Close TB
2. Find the profile directory by parsing the .ini
3. Match the %username% to their equivalent account from a flatfile or other data source.
4. Replace the existing prefs.js values with the new server values -or- replace prefs.js with a very basic prefs.js and fill in the blanks
posted by samsara at 12:34 PM on November 30, 2011

well, the nice thing is %username% is their email address / login, its hosted gmail, so not

So once I know %username% (which is synced via LDAP to googles servers for their mail), I can just do

Apparently we have powershell on everyones machine (Windows 7 or XP), or close to everyone. So I guess I need to learn powershell. I'd look at making it a run at login option on their workstations, so once users triggered a migration (which kicks off an entirely different process for the imap files to be copied to the server, not how I would have planned it), they can be instructed to reboot their machines for the thunderbird changes to happen.

Next option: how to do the same thing for outlook users?
posted by mrzarquon at 1:06 PM on November 30, 2011

Some more searching has turned up some prewritten powershell stuff on how to easily set a users firefox preference fields, so atleast I have some more starting point, will keep folks updated.
posted by mrzarquon at 1:26 PM on November 30, 2011

Heh, Dean's a colleague of mine and we worked together on autoconfiguring Mozilla products for this client. He did some great work tightening, abstracting, and tidying our autoconfigs. It's been a while but if I remember correctly the autoconfiguration gets accessed at every run of the app, not just during profile setup. I remember that we were able to lock/unlock various settings at deployment.

The good thing about this is it means they don't have to have been using MCD all along; you can deploy and activate an autoconfig JavaScript and it will take effect. Of course this is much harder if your users are running various multiple Thunderbird installations. It might be worthwhile to look at first moving the users to a network-mounted or package-installed managed Thunderbird configuration which you configure.

Some of the settings I remember being buggy in that they would only take effect once. But they were few and far between. Mail was also interesting. However I believe you can create new account indices and those will not conflict with existing ones. I think this is what we did when the client got acquired and needed users migrated to new corporate mailboxes. So that was a situation almost identical to yours except that users were already set up with autoconfig.

Apologies for the vague response; I just had an appendectomy last night. But if you're interested I can look through my notes from that project and see what I can find, and see if I can point Dean to this thread too. I know he does consulting as well so that might be an option if needed.
posted by vsync at 1:30 PM on November 30, 2011

« Older How do I turn job inquiries into good networking...   |   How to fix stained wok? Newer »
This thread is closed to new comments.