2008年12月17日星期三

一个自己用的东东——自制超强的portable版firefox

自制portable版firefox方法:
首先,你需要全新安装一个firefox,安装完以后,不要立刻运行,先去修改桌面上的firefox快捷方式,增加-p参数:
即将目标由"D:\Mozilla Firefox 3.1 Beta 2\firefox.exe"修改为"D:\Mozilla Firefox 3.1 Beta 2\firefox.exe" -p
修改完以后,运行,提示创建配置文件。
跟firefox目录呆在同一个目录吧!
我创建的配置文件目录名为fxprofile,看上面可以知道我的firefox版本为3.1 beta2。
好了,这样完毕以后,我的D盘下面,跟firefox有关的,有两个目录:Mozilla Firefox 3.1 Beta 2和fxprofile,分别保存着firefox应用程序及其配置文件。
这样,安装的扩展,个人的用户数据等等,都会被保存在D盘fxprofile目录下。
随便折腾吧!安装扩展吧!用about:config挖掘firefox的无限潜力吧!
搞好了就可以打包了。

本来这样就算是portable版本了,但是我们要超强的!一步搞定!
所以还要修改几个细节。
在一个没有安装firefox/opera/chrome/safari用的flash插件的机器上,flash是无法显示的。
从 C:\WINDOWS\system32\Macromed\Flash 拷贝一个npswf32.dll到D盘firefox程序目录\plugins\下面。
这样flash就正常了。为了避免这个dll在firefox启动时不加载,安全一点,注册下:
regsvr32 "D:\Mozilla Firefox 3.1 Beta 2\plugins\npswf32.dll"

这就完美了么?第一次启动firefox,还必须指定配置文件目录……有点小麻烦。
firefox的配置文件保存在哪儿,是由C:\Documents and Settings\Administrator\Application Data\Mozilla\Firefox\profiles.ini所控制的。
文件内容如下:
[General]
StartWithLastProfile=1

[Profile0]
Name=默认用户
IsRelative=0
Path=D:\fxprofile
Default=1

在一台没有安装过firefox的机器上,想让portable版本自动找到配置文件,需要:
mkdir "C:\Documents and Settings\Administrator\Application Data\Mozilla\Firefox"
copy /y D:\profiles.ini "C:\Documents and Settings\Administrator\Application Data\Mozilla\Firefox\"

创建C:\Documents and Settings\Administrator\Application Data\Mozilla\Firefox目录,并且把profiles.ini丢进去。

完美了么?
还差那么一点点!
解压firefox,还要创建桌面快捷方式,而且bat文件还需要运行,不如自解压来得方便。

摸索了好久,终于为自解压文件写好了注释。

D盘文件结构:
D:\
2009-01-19 01:07

fxprofile
2009-01-19 00:45
Mozilla Firefox 3.1 Beta 2
2008-12-17 09:44 115 profiles.ini
2008-12-17 09:51 255 reg_plugin_and_ext.bat

reg_plugin_and_ext.bat用来注册flash,并且指定配置文件目录。
内容如下:
@echo off
regsvr32 "D:\Mozilla Firefox 3.1 Beta 2\plugins\npswf32.dll"
mkdir "C:\Documents and Settings\Administrator\Application Data\Mozilla\Firefox"
copy /y D:\profiles.ini "C:\Documents and Settings\Administrator\Application Data\Mozilla\Firefox\"

这几个目录一起打包,创建winrar自解压文件。
自解压文件注释如下:
Title=坤哥的firefox自动安装程序

;本安装程序默认将执行以下操作:
;解压mozilla firefox程序以及配置目录fxprofile到D盘;
;自动注册mozilla flash支持(NPSWF32.dll)
;自动创建firefox桌面快捷方式

path=D:\
;mozilla firefox程序以及配置目录fxprofile 默认解压到D盘。
Overwrite=1
;如果目标存在则无需提示直接覆盖。
silent=2
;安静模式。安静模式2,显示解压缩窗口。安静模式1,完全没有任何提示,只看到鼠标忙,就像中毒!
Shortcut=D,"D:\Mozilla Firefox 3.1 Beta 2\firefox.exe",,"Firefox网页浏览器","Firefox,Rediscovery The Web!"
;在桌面为firefox创建快捷方式。
;快捷方式名称为 Firefox,Rediscovery The Web!备注为 Firefox网页浏览器,可以 按需修改。
setup=reg_plugin_and_ext.bat
;解压结束后运行bat。完成flash插件的注册以及配置目录的指定。

到这里差不多解析完毕。
同学们有什么不懂的地方可以留言提问。

没有评论:

发表评论