hi,
i wrote a similar script some time ago (to switch konqueror and firefox settings). correct me if this is just a linux thing, but
in the case of firefox, i think you should rather switch proxies in the "user.js" file, because it wont be overwritten if you already have an instance of firefox running. (as written in the prefs.js file itself)