[这个贴子最后由lucky0504在 2005/03/04 09:17pm 第 7 次编辑]
经过上面的介绍我们已经了解了RunOnceEx的原理了,下面我们进入本文的正题---用inf来添加注册表键值.
还是让我们首先来了解一下Windows XP 安装的时间过程吧.(以下源自www.cctips.com)
================================================================================
文字模式的安装界面
1. 载入驱动程序
2. 复制安装过程需要的文件到硬盘
3. 复制$OEM$文件夹的内容到硬盘
4. 重启动电脑...
图形模式的安装界面
1. DetachedProgram在第T39分钟从winnt.sif执行
2. 安装设备
3. 安装网络
4. 安装开始菜单项目
5. 注册组件
6. svcpack.inf在第T-13分钟被执行
7. cmdlines.txt在第T-12分钟被执行
8. [SetupParams]在第T-9分钟从winnt.sif被执行
9. 保存设置
10. 删除临时文件并重启动...
第一次登录
1. Windows XP把你登入并载入个人设置
2. [GuiRunOnce]从winnt.sif或RunOnceEx下被同时执行
3. 载入桌面和任务栏
================================================================================
通过批处理写入注册表的方法会被cmdlines.txt调用,在第T-12分钟执行,然后软件在第一次登录时的第2步执行.其实在T-13分钟之前RunOnceEx键其实已经执行过一次了.而这次执行RunOnceEx键时由于我们还没有写入任何软件安装信息,所以是不会执行无人职守安装的.我们如果可以在此之前写入注册表的话,就可以利用这个机会来安装了,那样的话就不用进入系统后再执行安装了,这样的好处就是有些软件或补丁安装后需要重启计算机,在T-13分钟之前的RunOnceEx键执行安装后恰巧可以利用系统的自动重启来完成这个过程.下面就来介绍用hivesft.inf来写入RunOnceEx键的集成方法.
首先我们还是要利用\$OEM$\$1\目录来复制安装文件,由于我没能找到在hivesft.inf中指定光驱路径的方法,所以还是要复制安装文件到硬盘中.目录结构如下图:
hivesft.inf文件是在文字模式的安装界面(蓝屏\黄色滚动条)过程的最后自动被调用的,用途是完成注册表配置.我们正好可以利用它.
进入Windows XP的i386目录我们可以看到hivecls.inf,hivedef.inf,hivesft.inf,hivesys.inf,hiveusd.inf几个文件,将它们打开不难发现,他们的内容都是用来写入注册表的,不同的文件指向不同的注册表位置.我们只要打开HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx对应的hivesft.inf文件搜索到相应键值的位置后将以下内容加入即可.
================================================================================
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx",,0x00000012
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx",Title,0,"安装常用软件和系统更新"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx",Flags,0x00010001,20
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install01",,,"安装 影音风暴 V5"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install01",1,,"..\Install\Software\StormCodec\StormCodec.exe /quickasso /skipcheck /skipcnnic /S"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install03",,,"安装 FlashGet V1.65"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install03",1,,"..\Install\Software\Flashget\FG165B1.EXE /S"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install04",,,"安装 WinRAR V3.3"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install04",1,,"..\Install\Software\WinRAR\winrar.exe /s"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install05",,,"安装 ACDSee V3.1"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install05",1,,"..\Install\Software\ACDSee\ACDSee.exe /S"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install06",,,"安装 QQ2005 贺岁版"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install06",1,,"..\Install\Software\QQ\Setup.exe /verysilent"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install07",,,"安装 Winamp 5.05 迷你版"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install07",1,,"..\Install\Software\Winamp\Setup.exe /verysilent"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install08",,,"安装 系统安全更新"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install08",01,,"..\Install\Software\Hotfixs\WindowsXP-KB834707-x86-chs.exe /quiet /norestart"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install08",02,,"..\Install\Software\Hotfixs\WindowsXP-KB873339-x86-CHS.exe /quiet /norestart"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install08",03,,"..\Install\Software\Hotfixs\WindowsXP-KB885835-x86-CHS.exe /quiet /norestart"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install08",04,,"..\Install\Software\Hotfixs\WindowsXP-KB885836-x86-CHS.exe /quiet /norestart"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install08",05,,"..\Install\Software\Hotfixs\WindowsXP-KB885884-x86-chs.exe /quiet /norestart"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install08",06,,"..\Install\Software\Hotfixs\WindowsXP-KB886185-x86-chs.exe /quiet /norestart"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install08",07,,"..\Install\Software\Hotfixs\WindowsXP-KB886677-x86-chs.exe /quiet /norestart"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install08",08,,"..\Install\Software\Hotfixs\WindowsXP-KB890830-x86-CHS.exe /Q"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install08",09,,"..\Install\Software\Hotfixs\WindowsXP-KB885222-x86-CHS.exe /quiet /norestart"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install08",10,,"..\Install\Software\Hotfixs\WindowsXP-KB890175-x86-CHS.exe /quiet /norestart"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install08",11,,"..\Install\Software\Hotfixs\WindowsXP-KB887797-x86-chs.exe /quiet /norestart"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install08",12,,"..\Install\Software\Hotfixs\WindowsXP-KB867282-x86-CHS.exe /quiet /norestart"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install08",13,,"..\Install\Software\Hotfixs\WindowsXP-KB873333-x86-CHS.exe /quiet /norestart"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install08",14,,"..\Install\Software\Hotfixs\WindowsXP-KB885250-x86-CHS.exe /quiet /norestart"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install08",15,,"..\Install\Software\Hotfixs\WindowsXP-KB887472-x86-chs.exe /quiet /norestart"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install08",16,,"..\Install\Software\Hotfixs\WindowsXP-KB888113-x86-CHS.exe /quiet /norestart"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install08",17,,"..\Install\Software\Hotfixs\WindowsXP-KB888302-x86-CHS.exe /quiet /norestart"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install08",18,,"..\Install\Software\Hotfixs\WindowsXP-KB890047-X86-CHS.exe /quiet /norestart"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install08",19,,"..\Install\Software\Hotfixs\WindowsXP-KB891781-x86-CHS.exe /quiet /norestart"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install08",20,,"..\Install\Software\Hotfixs\WindowsXP-KB887742-x86-CHS.exe /quiet /norestart"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install09",,,"安装 .NET Framework 1.1 组件"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install09",1,,"..\Install\Software\Hotfixs\DOTNETFW.EXE"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install09",2,,"..\Install\Software\Hotfixs\LANGPACK.EXE"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install09",3,,"..\Install\Software\Hotfixs\NDP1.1sp1-KB867460-X86.exe /Q"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install09",4,,"..\Install\Software\Hotfixs\NDP1.1sp1-KB886903-X86.exe /Q"
================================================================================
当然大家不要照搬以上内容,有些部分我们可能不一样,例如QQ 2005本来是没有 /verysilent这个参数的,这个是由于我将它重新封装了一遍,还有 .NET Framework 1.1 组件是经过打包的,所以看不到安装参数.将hivesft.inf保存好即可.要注意的是这里的安装程序的路径是"..\Install\Software\***\*.*",其中系统分区用".."来表示.这点很重要.如果哪位朋友知道如何指向光驱目录,希望也贴出来,大家分享.剩下的工作就是创建新用户,注册表调整和删除安装文件了,这些工作完全可以利用Cmdlines.txt调用来完成,我是利用xplode 4.0来完成的,这样做可以完全替代丑陋的批处理窗口。这个xplode新版本相比以前的版本有了很大提高,其中最主要的一个功能就是可以实现无界面的模式。
我的cmdlines.txt内容如下:
[COMMANDS]
".\XPlode\XPlode.exe"
"REGEDIT /S RegTweaks.reg"
第一行是调用XPlode进行建立用户,自动登陆,Flashget注册,和删除安装文件等工作.
第二行是进行注册表的调整.我的调整内容如下,大家可以进行更为个性化的设置.
================================================================================
Windows Registry Editor Version 5.00
;禁止蓝屏后的自动重启动
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CrashControl]
"AutoReboot"=dword:00000000
;加快关机速度
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control]
"WaitToKillServiceTimeout"="3000"
;通过删除共享的计划任务加速网络邻居的浏览
[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RemoteComputer\NameSpace\{D6277990-4C6A-11CF-8D87-00AA0060F5BF}]
;禁止Windows漫游气球提醒
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Applets\Tour]
"RunCount"=dword:00000000
;禁用Messenger服务(为了评比垃圾信息,而不会影响你的Windows/MSN Messenger)
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Messenger]
"Start"=dword:00000004
;从开始菜单中删除最近打开的文档项目
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"NoRecentDocsMenu"=dword:00000001
;经典搜索,在标题栏和地址栏显示完整路径
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState]
"FullPath"=dword:00000001
"FullPathAddress"=dword:00000001
"Use Search Asst"="no"
"Settings"=hex:0c,00,02,00,1b,01,e7,77,60,00,00,00
;允许重命名回收站
[HKEY_CLASSES_ROOT\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\ShellFolder]
"Attributes"=hex:50,01,00,20
"CallForAttributes"=dword:00000000
;Change MenuShowDelay (开始菜单读取速度)
[HKEY_CURRENT_USER\Control Panel\Desktop]
"MenuShowDelay"="2"
;Prevents Internet Explorer windows from being reused
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main]
"AllowWindowReuse"=dword:00000000
;关闭视频文件预览 (allowing you to move/rename/delete without errors)
[-HKEY_CLASSES_ROOT\.avi\ShellEx]
[-HKEY_CLASSES_ROOT\.mpg\ShellEx]
[-HKEY_CLASSES_ROOT\.mpe\ShellEx]
[-HKEY_CLASSES_ROOT\.mpeg\ShellEx]
;Disable System Restore Service 关闭系统还原服务
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\srservice]
"Start"=dword:00000004
;Disable Remote Registry Service 关闭远程修改注册表服务
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\RemoteRegistry]
"Start"=dword:00000004
================================================================================
补充一下:如果按照以下方法设置hivesft.inf可以得到无界面的安装模式.
================================================================================
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx",,0x00000012
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install",1,,"..\Install\Software\StormCodec\StormCodec.exe /quickasso /skipcheck /skipcnnic /S"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install",2,,"..\Install\Software\Flashget\FG165B1.EXE /S"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install",3,,"..\Install\Software\WinRAR\winrar.exe /s"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install",4,,"..\Install\Software\ACDSee\ACDSee.exe /S"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install",5,,"..\Install\Software\QQ\Setup.exe /verysilent"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install",6,,"..\Install\Software\Winamp\Setup.exe /verysilent"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install",7,,"..\Install\Software\MSN\MSN.exe"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install",8,,"..\Install\Software\DOTNETFW.EXE"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\install",9,,"..\Install\Software\LANGPACK.EXE"
================================================================================
如此设置后第一次以指定用户登录系统后就完成了软件安装,注册表调整等操作.呵呵,由于时间仓促,没有进行任何的准备工作,并且本人的水平有限.所以文中难免出现纰漏,希望大家指正,我会及时更改.由于此hivesft.inf文件是我无意中发现的,同时我目前只再XP下测试成功,所以不敢保证hivesft在其他系统中的通用性,以后一旦我在其他系统中测试成功我会补充这篇帖子的.好了,这次先说这么多吧,希望大家批评指正!