所以我有一个 Windows 10 无人值守应答文件。我得到了跳过 OOBE 屏幕、启用管理员帐户和复制配置文件的部分。我正在尝试设置应答文件以运行 PowerShell 脚本,以从我从开始菜单导出的 xml 文件中导入开始菜单。该文件位于映像的 C 驱动器上,并且路径已验证。
但是,当我将此 Powershell 命令添加到应答文件并运行 sysprep 并重新启动时,我在设置 Windows 时收到以下错误:“Windows 无法解析或处理无人值守应答文件 C:\Windows\Panther\unattend.xml 以传递 [specialize]。应答文件中指定的组件或设置不存在。”
这是有问题的unattend.xml:
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<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>
<Password>
<Value>P@ssword</Value>
<PlainText>true</PlainText>
</Password>
<Username>Administrator</Username>
<Enabled>true</Enabled>
<LogonCount>5</LogonCount>
</AutoLogon>
<StartTiles>
<PromoteOEMTiles>false</PromoteOEMTiles>
</StartTiles>
<WindowsFeatures>
<ShowInternetExplorer>true</ShowInternetExplorer>
<ShowMediaCenter>false</ShowMediaCenter>
<ShowWindowsMail>false</ShowWindowsMail>
<ShowWindowsMediaPlayer>true</ShowWindowsMediaPlayer>
</WindowsFeatures>
<CopyProfile>true</CopyProfile>
<DisableAutoDaylightTimeSet>false</DisableAutoDaylightTimeSet>
</component>
<component name="Microsoft-Windows-Deployment" 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">
<FirstLogonCommands>
<RunSynchronousCommand wcm:action="add">
<Description>Set Powershell Execution Policy to Unrestricted</Description>
<Path>powershell.exe Set-ExecutionPolicy Unrestricted -force</Path>
<Order>3</Order>
</RunSynchronousCommand>
<SynchronousCommand wcm:action="add">
<Order>4</Order>
<CommandLine>powershell.exe Import-StartLayout –LayoutPath C:\Installs\StartMenu.xml –MountPath $env:SystemDrive\</CommandLine>
<Description>Start Menu</Description>
</SynchronousCommand>
</FirstLogonCommands>
</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>
<HideLocalAccountScreen>true</HideLocalAccountScreen>
<HideEULAPage>true</HideEULAPage>
<HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>
<HideOnlineAccountScreens>true</HideOnlineAccountScreens>
<HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
<SkipUserOOBE>true</SkipUserOOBE>
<SkipMachineOOBE>true</SkipMachineOOBE>
</OOBE>
<UserAccounts>
<AdministratorPassword>
<Value>P@ssword</Value>
<PlainText>true</PlainText>
</AdministratorPassword>
</UserAccounts>
</component>
</settings>
<cpi:offlineImage cpi:source="wim:c:/users/tester/desktop/win10/sources/install.wim#Windows 10 Pro" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>
这是我最后一个正常工作的 unattend.xml:
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<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">
<WindowsFeatures>
<ShowWindowsMail>false</ShowWindowsMail>
<ShowInternetExplorer>true</ShowInternetExplorer>
</WindowsFeatures>
<CopyProfile>true</CopyProfile>
<DisableAutoDaylightTimeSet>false</DisableAutoDaylightTimeSet>
<AutoLogon>
<Password>
<Value>Password123!</Value>
<PlainText>true</PlainText>
</Password>
<Username>Administrator</Username>
<Enabled>true</Enabled>
<LogonCount>5</LogonCount>
</AutoLogon>
<UserAccounts>
<AdministratorPassword>
<Value>Password123!</Value>
<PlainText>true</PlainText>
</AdministratorPassword>
</UserAccounts>
</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>
<HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
<HideOnlineAccountScreens>true</HideOnlineAccountScreens>
<SkipMachineOOBE>true</SkipMachineOOBE>
<SkipUserOOBE>true</SkipUserOOBE>
<HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>
</OOBE>
<WindowsFeatures>
<ShowInternetExplorer>true</ShowInternetExplorer>
<ShowWindowsMail>false</ShowWindowsMail>
<ShowWindowsMediaPlayer>true</ShowWindowsMediaPlayer>
</WindowsFeatures>
<BluetoothTaskbarIconEnabled>false</BluetoothTaskbarIconEnabled>
<UserAccounts>
<AdministratorPassword>
<Value>Password123</Value>
<PlainText>Password123</PlainText>
</AdministratorPassword>
</UserAccounts>
</component>
</settings>
<cpi:offlineImage cpi:source="wim:c:/users/tester/desktop/win10/sources/install.wim#Windows 10 Pro" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>
我已在无人值守应答文件中使用标签设置了 PowerShell 命令。
这也是我在 Sysprep 之后从 C:\Windows\Panther 中提取的日志...
2018-07-23 10:38:29, Error [setup.exe] SMI data results dump: Source = Name: Microsoft-Windows-Deployment, Language: neutral, ProcessorArchitecture: amd64, PublicKeyToken: 31bf3856ad364e35, VersionScope: nonSxS, /settings/FirstLogonCommands
2018-07-23 10:38:29, Error [setup.exe] SMI data results dump: Description = Setting is not defined in this component.
2018-07-23 10:38:29, Error [0x060432] IBS The provided unattend file is not valid; hrResult = 0x80220001
2018-07-23 10:38:29, Error [0x060565] IBS Callback_Unattend_InitEngine:The provided unattend file [C:\Windows\Panther\unattend.xml] is not a valid unattended Setup answer file; hr = 0x1, hrSearched = 0x1, hrDeserialized = 0x0, hrImplicitCtx = 0x0, hrValidated = 0x1, hrResult = 0x80220001
2018-07-23 10:38:29, Error [0x0600c2] IBS Callback_Unattend_InitEngine:An error occurred while finding/loading the unattend file; hr = 0x1, hrResult = 0x80220001[gle=0x00000490]
答案1
2018-07-23 10:38:29, Error [setup.exe] SMI data results dump: Source = Name: Microsoft-Windows-Deployment, Language: neutral, ProcessorArchitecture: amd64, PublicKeyToken: 31bf3856ad364e35, VersionScope: nonSxS, /settings/FirstLogonCommands
2018-07-23 10:38:29, Error [setup.exe] SMI data results dump: Description = Setting is not defined in this component.
Windows 安装程序指示您FirstLogonCommands
在无人值守文件中将“ ”块放入了错误的路径中。
您使用两种不同的结构来运行命令。您使用的是“RunSynchronousCommand”和“SynchronousCommand”。
首先,你应该使用Windows 系统映像管理器创建无人值守文件。这将确保它们的格式正确。
这里的问题是您正在使用“运行同步命令“在专门化过程或 auditUser 过程中工作的块。它应该包含在“RunSynchronous”块中。
您输入的是“同步命令“在第一个用户登录系统后,在 oobeSystem 阶段运行的块。但是,您已将其放入专门阶段。
RunSynchronousCommand 块必须包含在“RunSynchronous”块中,并位于 Specialize 或 auditUser 阶段。SynchronousCommand 块只能位于 oobeSystem 阶段。有关 Windows 安装程序配置阶段及其运行时间的说明,请参见此处:https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/windows-setup-configuration-passes
您需要决定何时运行这些命令,然后通过将命令放置在正确的位置来正确格式化无人值守文件。同样,Windows 系统映像管理器不会验证此文件。
最有可能的是,您只想在 oobeSystem 阶段使用“SynchronousCommand”。但是,请注意,Windows 10 不会同步运行这些命令。与 Microsoft 在文档中指定的相反,Windows 不会等待这些命令完成后再让用户登录。这是 Windows 10 的新功能。