Webmaster 发表于 2015-11-30 17:52

Windows 7封装笔记

本帖最后由 Webmaster 于 2015-12-1 19:25 编辑

Windows 7封装笔记


一、原装安装
这个不用多说了吧。
安装到了“欢迎使用 Windows”,不输入用户名,直接按下Shift+Ctrl+F3进入审核模式,然后启动后会有sysprep一个窗口,关掉了事。

装好了先做个镜像备份,或者快照(VM虚拟机功能)。

对了,还有最好用专业版的镜像来安装,先卖个关子。


二、安装常用的运行库和软件。

VC运行库
.NET Framework
directx_redist
Flash插件
Office等。


三、Windows Update更新
这个也不用说了吧。有个推荐更新最好也装上,叫kb2852386,后面会提到。
更新之前,最好先手动更新Windows Update Agent到最新(说起来都是泪)。如https://support.microsoft.com/en-us/kb/3102810。


四、添加驱动到驱动库。
如英特尔100系列主板的USB3驱动,没有这个鼠键可能用不了。
例如将c:\drivers\usb1151\的驱动添加驱动库。
pnputil.exe -a c:\drivers\usb1151\*.inf


五、清理C盘
使用“磁盘清理”清理C盘,删除更新下载目录的文件。
安装kb2852386推荐更新,这个更新会使磁盘清理多了一项Windows更新清理功能。


下面两个建议不要删除,因为删除了之后,捕捉的wim镜像,好像仅小了200M左右,还可能是kb2852386清理更新的功劳。
C:\WINDOWS\SoftwareDistribution\DataStore\DataStore.edb
C:\Windows\winsxs\Backup\


所有搞好之后,记得备份镜像或者快照。


六、使用sysprep。
所以再检查一遍,重启,终于要用到每次重启都出来的sysprep窗口了。选上通用,其它的不变。


等它搞好之后,重启进入PE,抓取wim镜像(推荐),当然也可以GHOST之类的。
如果想懒一下,直接添加到原版的\sources\install.wim里。
将\sources\install.wim复制到D:。
imagex /append C: D:\install.wim "Windows 7 专业版 更新到2015年11月" /verify




如果你是使用映像工具安装,到这儿就结束。




如果想使用Win7的安装程序来安装,我们继续。


七、写入版本信息
imagex /info D:\install.wim 5 "Windows 7 专业版 更新到2015年11月" "Windows 7 专业版 更新到2015年11月" /flags "Professional"


八、建立镜像索引
先下载Windows AIK并安装,打开Windows系统映像管理器。


文件,选择映像,选中install.wim,然后选“Windows 7 专业版 更新到2015年11月”,接着会提示无法打开Windows映像编录文件,选是,会在同install.wim生成一个“install_Windows 7 专业版 更新到2015年11月.clg”。


八、制作应答文件,用来启用Administrator,跳过OOBE,为安装环境添加USB3驱动等
(还是在Windows系统映像管理器中)


2.1 启用Administrator
2.1.1在应答文件窗口,点击右键,新建应答文件


2.1.2在Windows镜像窗口,展开
Components->AMD64_Microsoft-Windows-Shell-Setup->AutoLogon,AutoLogon上右键“添加设置以传送4 specialize”。



2.1.3在应文件窗口,展开
specialize->x86_Microsoft-Windows-Shell-Setup
设定
CopyProFile:true


2.1.4
specialize->AMD64_Microsoft-Windows-Shell-Setup->AutoLogon。
设定
Enabled:true
logonCount:5
Username:Administrator




2.2跳过OOBE设置
2.2.1在Windows镜像窗口,展开
Components->AMD64_Microsoft-Windows-Shell-Setup->OOBE,OOBE上右键“添加设置以传送7 oobesystem”。



2.2.2在应文件窗口,展开
oobesystem->AMD64_Microsoft-Windows-Shell-Setup->OOBE。
设定
SkipMachineOOBE:true




2.3给PE安装环境添加驱动,如将U盘\drivers\usb1151的USB驱动添加到PE安装环境。
2.3.1在Windows镜像窗口,展开
Components->Microsoft-Windows-PnpCustomizationsWinPE,“添加设置以传送1 WindowsPE”



2.3.2在应文件窗口,展开
Components->Microsoft-Windows-PnpCustomizationsWinPE ,右键单击 DevicePaths,“插入新 PathAndCredentials”。将会出现一个新的 PathAndCredentials 列表项。

设定
Action:AddListItem
key:1
path:%configsetroot%\drivers\usb1151


2.3.3在应文件窗口,展开
Components->Microsoft-Windows-PnpCustomizationsNonWinPE,“添加设置以传送5 auditSystem”



2.3.4在应文件窗口,展开
auditSystem->Microsoft-Windows-PnpCustomizationsNonWinPE, ,右键单击 DevicePaths,“插入新 PathAndCredentials”。将会出现一个新的 PathAndCredentials 列表项。


设定
Action:AddListItem
key:2
path:%configsetroot%\drivers\usb1151




2.3.5
Components->Microsoft-Windows-PnpCustomizationsNonWinPE,“添加设置以传送 offlineServicing”


2.3.6
offlineServicing->Microsoft-Windows-PnpCustomizationsNonWinPE, ,右键单击 DevicePaths,“插入新 PathAndCredentials”。将会出现一个新的 PathAndCredentials 列表项。


设定
Action:AddListItem
key:3
path:%configsetroot%\drivers\usb1151



对于您访问的每个位置,添加单独的“PathAndCredentials”列表项。

通过添加多个 PathAndCredentials 列表项,就可以包含多个设备驱动程序路径。如果添加多个列表项,必须递增每个路径的 Key 值。例如,如果添加两个单独的驱动程序路径,则第一个路径使用 Key 的值为 1,第二个路径使用 Key 的值为 2。



最后在“文件”菜单上,单击“保存答案文件”,将答案文件保存为 Autounattend.xml,和驱动一起放到U盘根目录。将搞好的install.wim代替原版U盘\sources\install.wim。


(注:若镜像大于4G,U盘请用diskpart分成NTFS。不过了NTFS之后,要安装EFI的WIN,只能用MBR启动WIN8PE,应用镜像后写入EFI引导。详细《看制作U盘WIN7安装盘的三种方法 》、《EFI+GPT+WIN7简易安装说明》和《用GRUB4DOS 给U盘Win7原版安装盘 加上PE等维护工具 》)






附录1:升级到更高版本的 Windows
单击「开始」,依次指向“所有程序”和“Windows AIK”,右键单击“部署工具命令提示符”,然后选择“以管理员身份运行”。

装载映像
Dism /Mount-Wim /WimFile:C:\test\images\MyImage.wim /index:1 /MountDir:C:\test\offline

在提升的命令提示符下,列出可进行升级的版本。例如:
Dism /image:C:\test\offline /Get-TargetEditions
注意目标版本 ID。


在命令提示符下,指定希望升级到的版本。例如:
Dism /image:C:\test\offline /Set-Edition:Ultimate

卸载并保存映像
Dism /Unmount-Wim /MountDir:C:\test\offline /commit


当然也可以安装之后,打开控制面板里的Windows Anytime Upgrade,输入旗舰版正版号来升级。




附录2:Autounattend.xml文件示例。

<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
    <settings pass="offlineServicing">
      <component name="Microsoft-Windows-PnpCustomizationsNonWinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <DriverPaths>
                <PathAndCredentials wcm:action="add" wcm:keyValue="3">
                  <Path>%configsetroot%\drivers\usb1151</Path>
                </PathAndCredentials>
                <PathAndCredentials wcm:action="add" wcm:keyValue="4">
                  <Path>%configsetroot%\drivers\usb1155</Path>
                </PathAndCredentials>
            </DriverPaths>
      </component>
    </settings>
    <settings pass="windowsPE">
      <component name="Microsoft-Windows-PnpCustomizationsWinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <DriverPaths>
                <PathAndCredentials wcm:action="add" wcm:keyValue="1">
                  <Path>%configsetroot%\drivers\usb1151</Path>
                </PathAndCredentials>
                <PathAndCredentials wcm:action="add" wcm:keyValue="2">
                  <Path>%configsetroot%\drivers\usb1155</Path>
                </PathAndCredentials>
            </DriverPaths>
      </component>
    </settings>
    <settings pass="auditSystem">
      <component name="Microsoft-Windows-PnpCustomizationsNonWinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <DriverPaths>
                <PathAndCredentials wcm:action="add" wcm:keyValue="5">
                  <Path>%configsetroot%\drivers\usb1151</Path>
                </PathAndCredentials>
                <PathAndCredentials wcm:action="add" wcm:keyValue="6">
                  <Path>%configsetroot%\drivers\usb1155</Path>
                </PathAndCredentials>
            </DriverPaths>
      </component>
    </settings>
    <settings pass="specialize">
      <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <AutoLogon>
                <Username>Administrator</Username>
                <LogonCount>5</LogonCount>
                <Enabled>true</Enabled>
            </AutoLogon>
            <CopyProfile>true</CopyProfile>
      </component>
    </settings>
    <settings pass="oobeSystem">
      <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <OOBE>
                <SkipMachineOOBE>true</SkipMachineOOBE>
            </OOBE>
      </component>
    </settings>
    <cpi:offlineImage cpi:source="wim:d:/bak/boot/sources/install.wim#Windows 7 ULTIMATE Update 15-11" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>


EraserKing 发表于 2015-11-30 17:59

图全挂

Webmaster 发表于 2015-11-30 18:07

EraserKing 发表于 2015-11-30 17:59
图全挂

文字已经说明了,应该能看明白吧。

akitox 发表于 2015-12-1 13:03

看是能看明白..............

烙馍卷菜 发表于 2015-12-1 13:17

Webmaster 发表于 2015-12-1 14:13

烙馍卷菜 发表于 2015-12-1 13:17
超过4G就用不了FAT32不能UEFI启动是个蛋疼的问题,有没有什么好的解决办法? ...

没有,分割了,WIN7安装程序不认(Win10的安装程序可以,可以将镜像附加到WIN10里,做成多合一安装)。不过可以MBR启动WIN8以上PE,应用镜像后bcdboot C:\Windows /l zh-CN /s X: /f UEFI (X是EFI分区的盘符。)
然后重启设为EFI启动即可。

在已分好区,重装的情况下,EFI(ESP)盘符是不可见的,磁盘管理也不能重新分配,但可以用DiskGenius分配盘符(当然也可以用diskpart)。

jie2000 发表于 2015-12-1 16:04

刚好最近要搞个封装系统,感谢LZ

烙馍卷菜 发表于 2015-12-1 18:05

页: [1]
查看完整版本: Windows 7封装笔记