无忧启动论坛
标题:
Sysprep应答文件及封装测试小技巧个人总结
[打印本页]
作者:
yjqd
时间:
2018-12-24 22:11
标题:
Sysprep应答文件及封装测试小技巧个人总结
本帖最后由 yjqd 于 2018-12-25 08:27 编辑
环境:win7旗舰sp1 32位 在同一台电脑情况下
小技巧
有时需要多次封装测试,提前做好准备,减少麻烦:
1、执行全新oobe前将C:\Windows\System32\config下注册表配置单元system拷贝一份,当出现某些错误时,进入pe将system备份覆盖C:\Windows\System32\config中的System
2、保留硬件配置应答文件
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="generalize">
<component name="Microsoft-Windows-PnpSysprep" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DoNotCleanUpNonPresentDevices>true</DoNotCleanUpNonPresentDevices>
<PersistAllDeviceInstalls>true</PersistAllDeviceInstalls>
</component>
</settings>
</unattend>
安装过程中,安装设备阶段花的时间最长,执行全新oobe用了保留硬件配置应答文件,安装设备阶段极大缩短所需时间:
安装程序正在更新注册表设置-安装程序正在启动服务-安装程序正在安装设备(其实没安装)-安装程序正在正在应用系统配置-安装程序将在重新启动您的计算机后继续
3、处理完某个配置阶段后,Windows 安装程序将对缓存的应答文件添加注释,以表明该阶段已处理。
如果应答文件某一项被执行后,比如<settings pass="*">被执行了,就会变成<settings pass="*" wasPassProcessed="true">
所以某一项中有wasPassProcessed="true",就表示被执行了,系统不会再执行它,你可把wasPassProcessed="true"删掉,系统又会执行它
当然,Windows 安装程序将对缓存的应答文件添加的注释更多或修改了其它一些地方,比如应答文件中的用户密码和系统密钥等
注意:如果处在审核模式下,如果C:\Windows\Panther中有可用于auditsystem或audituser的应答文件,重启电脑时会执行应答文件,即没用命令指定应答文件也会执行
应答文件
应答文件中使用命令
同步命令RunSynchronous\RunSynchronousCommand
下面的组件中有同步命令,只能配置到4、6阶段 (4 specialize, 6 auditUser)
x86_Microsoft-Windows-Deployment_6.1.7601.17514_neutral/RunSynchronous
x86_Microsoft-Windows-Deployment_6.1.7601.17514_neutral/RunSynchronous/RunSynchronousCommand
下面的组件中有同步命令,只能配置到1阶段 (1 windowsPE)
x86_Microsoft-Windows-Setup_6.1.7600.16385_neutral/RunSynchronous
x86_Microsoft-Windows-Setup_6.1.7600.16385_neutral/RunSynchronous/RunSynchronousCommand
异步命令RunAsynchronous\RunAsSynchronousCommand
下面的组件中有异步命令,只能配置到4、6阶段 (4 specialize, 6 auditUser)
x86_Microsoft-Windows-Deployment_6.1.7601.17514_neutral/RunAsynchronous
x86_Microsoft-Windows-Deployment_6.1.7601.17514_neutral/RunAsynchronous/RunAsynchronousCommand
下面的组件中有异步命令,只能配置到1阶段 (1 windowsPE)
x86_Microsoft-Windows-Setup_6.1.7600.16385_neutral/RunAsynchronous
x86_Microsoft-Windows-Setup_6.1.7600.16385_neutral/RunAsynchronous/RunAsynchronousCommand
同步命令FirstLogonCommands/SynchronousCommand
下面的组件中有同步命令,只能配置到7阶段 (7 oobeSystem)
x86_Microsoft-Windows-Shell-Setup_6.1.7601.17514_neutral/FirstLogonCommands
x86_Microsoft-Windows-Shell-Setup_6.1.7601.17514_neutral/FirstLogonCommands/SynchronousCommand
异步命令FirstLogonCommands/SynchronousCommand
下面的组件中有异步命令,只能配置到7阶段 (7 oobeSystem)
x86_Microsoft-Windows-Shell-Setup_6.1.7601.17514_neutral/LogonCommands
x86_Microsoft-Windows-Shell-Setup_6.1.7601.17514_neutral/LogonCommands/AsynchronousCommand令
应答文件单项测试
拷贝用户配置文件
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="specialize">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CopyProfile>true</CopyProfile>
</component>
</settings>
</unattend>
审核模式重启把用户从users组删除应答文件
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="auditUser">
<component name="Microsoft-Windows-Deployment" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<RunAsynchronous>
<RunAsynchronousCommand wcm:action="add">
<Path>net LOCALGROUP users new /delete</Path>
<Description>Remove users from LOCALGROUP</Description>
<Order>1</Order>
</RunAsynchronousCommand>
</RunAsynchronous>
</component>
</settings>
</unattend>
作者:
aals
时间:
2018-12-24 22:35
发个文件来试试看了。
作者:
yjqd
时间:
2018-12-24 22:40
本帖最后由 yjqd 于 2018-12-25 11:42 编辑
应答文件加配置文件固定输入法栏在任务栏
配置文件"DefaultInput欢迎屏幕系统用户.xml"内容:
<?xml version="1.0" encoding="utf-8"?>
<gs:GlobalizationServices xmlns:gs="urn:longhornGlobalizationUnattend">
<!--User List-->
<gs:UserList>
<gs:User UserID="Current" CopySettingsToSystemAcct="true"/>
</gs:UserList>
</gs:GlobalizationServices>
执行全新oobe前,执行命令 control intl.cpl,,/f:"DefaultInput欢迎屏幕系统用户.xml"
执行全新oobe建立的新用户登陆后,输入法是固定在任务栏上的,注:不依赖于应答文件中的<CopyProfile>true</CopyProfile>
如果不执行全新oobe,只需要CopySettingsToDefaultUserAcct="true",那么在当前系统中建立新用户,切换用户用新用户登陆后,输入法是固定在任务栏上的;如果只使用CopySettingsToSystemAcct="true" ,测试记得不能固定在任务栏
也可修改注册表,定位至HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\Sysprep\Cleanup,对其右键设定
Adminstrators完全控制权限,删除右边数据为C:\Windows\System32\shsetup.dll,Sysprep_Cleanup_Shell的键值
应答文件加配置文件保持自己安装的输入法并设置为默认输入法
以极点五笔为例
配置文件"DefaultInput只添加极点输入法.xml"内容:
<?xml version="1.0" encoding="utf-8"?>
<gs:GlobalizationServices xmlns:gs="urn:longhornGlobalizationUnattend">
<!--User List-->
<gs:UserList>
<gs:User UserID="Current"/>
</gs:UserList>
<!--input preferences-->
<gs:InputPreferences>
<!--add jd keyboard-->
<gs:InputLanguageID Action="add" ID="0804:e0010804" Default="true"/>
</gs:InputPreferences>
</gs:GlobalizationServices>
应答文件中相关内容:
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="oobeSystem">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<FirstLogonCommands>
<SynchronousCommand wcm:action="add">
<Order>1</Order>
<CommandLine>control intl.cpl,,/f:"C:\Windows\Panther\DefaultInput.xml"</CommandLine>
</SynchronousCommand>
</FirstLogonCommands>
</component>
</settings>
</unattend>
作者:
yjqd
时间:
2018-12-24 22:41
本帖最后由 yjqd 于 2018-12-25 08:03 编辑
应答文件添加IE搜索引擎并设置为默认搜索引擎
应答文件和注册表的关系
安装系统时应答文件中有设置搜索引擎的项,系统安装完成后,注册表会写入相应的值,应答文件中的项名称和注册表中项名称不太一样,但它们之间有的是对应的:
应答文件(只有10项) 注册表(没标明数据类型的都是REG_SZ)
<FaviconURL> 从搜索引擎的网页提供搜索引擎ico图标 FaviconURL
<PreviewURL>
<ScopeDisplayName> 搜索引擎的名称 DisplayName
<ScopeKey> 在搜索引擎列表中的排位顺序
<ScopeUrl> 搜索引擎地址 URL
<SuggestionsURL> 搜索建议地址
<SuggestionsURL_JSON> 搜索建议地址 SuggestionsURL_JSON
<ShowSearchSuggestions> 是否显示搜索建议 ShowSearchSuggestions 1表示显示 REG_DWORD
<ScopeDefault> 设置默认搜索引擎 DefaultScope
<DisplayQuickPick>
如果手动在浏览器中添加某项搜索引擎,注册表中可能会出现键值OSDFileURL,它的数据比如为:
https://www.microsoft.com/cms/api/am/binary/RWiIg0
手动在浏览器中添加多个搜索引擎,它们注册表对应的键值OSDFileURL的数据只有最后一位不同
一般应答文件只需要<ScopeDisplayName>、<ScopeUrl>、<ScopeKey>就行了,如果要有搜索引擎图标,需要<FaviconURL>
怎样获得<ScopeUrl>、和<FaviconURL>的准确地址呢,可以手动在浏览器中添加某项搜索引擎,根据上面的对应关系在注册表中可找到
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\SearchScopes它下面中的各项表示各个搜索引擎
它的右边有DefaultScope,指定了默认搜索引擎是哪个,当某搜索引擎设置为默认搜索引擎时,是不能删除的,即只有非默认搜索引擎才能被删除
有的注册表中会出现SuggestionsURLFallback,它和SuggestionsUR、SuggestionsURL_JSON表示搜索建议
对应管理加载项-搜索提供程序-搜索建议,如果没有该键值或键值的数据不对,会出现不可用
有的注册表中会出现TopResultURLFallback,表示最匹配的结果搜索
对应管理加载项-搜索提供程序-最匹配的结果搜索,如果没有该键值或键值的数据不对,会出现不可用
具体是否出现这些项,可能由搜索引擎决定
当在网页选中文字右键就有比如"使用bing搜索","使用bing搜索"前面有bing的图标,<FaviconURL>填写正确的地址就行了,
当联网打开浏览器时,会自动获取下载ico图标到C:\Users\用户名\AppData\LocalLow\Microsoft\Internet Explorer\Services文件夹中,且文件名比如为search_{xxxxxx}.ico
浏览器会自动检测search_{xxxxxx}.ico是否存在,如果不存在,会自动从网上获取(必应搜索引擎现在好像不能获取到ico图标了)
注册表会出现FaviconPath,它的数据为:比如C:\Users\用户名\AppData\LocalLow\Microsoft\Internet Explorer\Services\search_{xxxxxx}.ico
设置IE主页添加百度并设为默认搜索引擎
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="specialize">
<component name="Microsoft-Windows-IE-InternetExplorer" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Home_Page>https://www.ifeng.com/</Home_Page>
<SearchScopes>
<Scope wcm:action="add">
<FaviconURL>http://www.baidu.com/favicon.ico</FaviconURL>
<ScopeDefault>true</ScopeDefault>
<SuggestionsURL_JSON>http://suggestion.baidu.com/su?wd={searchTerms}&action=opensearch&ie=utf-8&from=ie8</SuggestionsURL_JSON>
<ScopeKey>SearchProvider1</ScopeKey>
<ScopeDisplayName>百度</ScopeDisplayName>
<ShowSearchSuggestions>true</ShowSearchSuggestions>
<ScopeUrl>http://www.baidu.com/s?wd={searchTerms}&ie=utf-8</ScopeUrl>
</Scope>
</SearchScopes>
</component>
</settings>
</unattend>
作者:
yjqd
时间:
2018-12-25 08:06
本帖最后由 yjqd 于 2018-12-25 08:51 编辑
应答文件综合测试
跳过用户oobe设置面板,最简单是以管理员Administrator登陆
<?xml version='1.0' encoding='utf-8'?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="oobeSystem">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" 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>
<AutoLogon>
<Username>Administrator</Username>
<Enabled>true</Enabled>
<LogonCount>1</LogonCount>
<Password>空字符串</Password>
</AutoLogon>
<UserAccounts>
<AdministratorPassword>空字符串</AdministratorPassword>
</UserAccounts>
</component>
</settings>
</unattend>
强迫症们可能需要知道某项是怎么跳过的:
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="oobeSystem">
<component name="Microsoft-Windows-International-Core" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<InputLocale>zh-CN</InputLocale>
<SystemLocale>zh-CN</SystemLocale>
<UILanguage>zh-CN</UILanguage>
<UILanguageFallback>zh-CN</UILanguageFallback>
<UserLocale>zh-CN</UserLocale>
</component>
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" 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>
<ProtectYourPC>3</ProtectYourPC>
<HideEULAPage>true</HideEULAPage>
<HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
<NetworkLocation>Home</NetworkLocation>
</OOBE>
<TimeZone>China Standard Time</TimeZone>
<AutoLogon>
<Username>new</Username>
<Enabled>true</Enabled>
<LogonCount>1</LogonCount>
<Password>
<Value>UABhAHMAcwB3AG8AcgBkAA==</Value>
<PlainText>false</PlainText>
</Password>
</AutoLogon>
<UserAccounts>
<LocalAccounts>
<LocalAccount wcm:action="add">
<Name>new</Name>
<Group>administrators</Group>
<DisplayName></DisplayName>
<Description></Description>
<Password>
<Value>UABhAHMAcwB3AG8AcgBkAA==</Value>
<PlainText>false</PlainText>
</Password>
</LocalAccount>
</LocalAccounts>
</UserAccounts>
</component>
</settings>
<settings pass="specialize">
<component name="Microsoft-Windows-Security-Licensing-SLC-UX" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SkipAutoActivation>true</SkipAutoActivation>
</component>
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ComputerName>*</ComputerName>
<ProductKey>00000-00000-00000-00000-00000</ProductKey>
<CopyProfile>true</CopyProfile> 拷贝用户配置
</component>
<component name="Microsoft-Windows-IE-InternetExplorer" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Home_Page>https://www.msn.cn/zh-cn/</Home_Page> 设置IE主页
</component>
</settings>
</unattend>
作者:
yjqd
时间:
2018-12-25 08:18
本帖最后由 yjqd 于 2018-12-25 08:32 编辑
应答文件放哪里优先搜索顺序并加载 无人值守应答文件使用方法
Windows 安装程序自动化概述
https://msdn.microsoft.com/zh-cn ... /apps/dn938367.aspx
用于自动化 OOBE 的设置
https://msdn.microsoft.com/zh-cn ... s/hardware/dn938324
(v=vs.85).aspx
作者:
yjqd
时间:
2018-12-25 08:35
本帖最后由 yjqd 于 2018-12-25 09:04 编辑
跳过oobe用户设置面板
用于自动化 OOBE 的设置
https://msdn.microsoft.com/zh-cn ... s/hardware/dn938324
(v=vs.85).aspx
自动化 Windows 安装程序
https://msdn.microsoft.com/zh-cn ... s/hardware/dn898487
(v=vs.85).aspx
SkipUserOOBE
https://docs.microsoft.com/en-us ... dows-vista/cc721948
(v%3dws.10)
SkipMachineOOBE
https://docs.microsoft.com/en-us ... dows-vista/cc765947
(v=ws.10)
作者:
yjqd
时间:
2018-12-30 20:17
本帖最后由 yjqd 于 2018-12-30 20:21 编辑
应答文件添加注释
应答文件或配置文件内容中如果有中文,必须把应答文件或配置文件保存为UTF-8格式
应答文件添加注释
格式:
<!-- 注释内容 -->
比如:
内容可以是英文也可以是中文
<!-- Note, the IEWelcomeMsg setting does not appear in this example code.-->
<!-- 首次登陆运行命令共3个 -->
<FirstLogonCommands>
<!-- 注册表增加记事本打开 -->
<SynchronousCommand wcm:action="add">
<Order>1</Order>
<CommandLine>REG ADD HKLM\SOFTWARE\Classes\*\shell\notepad /ve /d "用记事本打开" /f</CommandLine>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<Order>2</Order>
<CommandLine>REG ADD HKLM\SOFTWARE\Classes\*\shell\notepad\command /ve /d "notepad %1" /f</CommandLine>
</SynchronousCommand>
<!-- 注册表设置记事本自动换行 -->
<SynchronousCommand wcm:action="add">
<Order>3</Order>
<CommandLine>REG ADD HKCU\Software\Microsoft\Notepad /v fWrap /t REG_DWORD /d "0x00000001" /f</CommandLine>
</SynchronousCommand>
</FirstLogonCommands>
作者:
金
时间:
2019-6-28 09:51
感谢楼主热心分享
欢迎光临 无忧启动论坛 (http://bbs.wuyou.net/)
Powered by Discuz! X3.3