我安装了 2 个 Windows,它们完全相同,设置相同,程序相同。唯一的区别是 Windows 架构不同,一个是 32 位,另一个是 64 位。
当我使用以下应答文件对 32 位安装进行系统准备时:
<?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">
<FolderLocations>
<ProfilesDirectory>U:\Users</ProfilesDirectory>
</FolderLocations>
<FirstLogonCommands>
<SynchronousCommand wcm:action="add">
<CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -NonInteractive -ExecutionPolicy Bypass -File C:\Windows\System32\Scripts\PinTaskbarItems\Managetaskbar\Taskband.ps1</CommandLine>
<Description>Sets the pinned taskbar items and restarts the explorer process</Description>
<Order>1</Order>
<RequiresUserInput>false</RequiresUserInput>
</SynchronousCommand>
</FirstLogonCommands>
</component>
</settings>
<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">
<DesktopOptimization>
<ShowWindowsStoreAppsOnTaskbar>false</ShowWindowsStoreAppsOnTaskbar>
</DesktopOptimization>
<CopyProfile>true</CopyProfile>
<DoNotCleanTaskBar>true</DoNotCleanTaskBar>
<EnableStartMenu>true</EnableStartMenu>
</component>
</settings>
<cpi:offlineImage cpi:source="wim:c:/users/bas/desktop/iso's/x32/install.wim#Windows 10 Pro" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>
目前只涉及FirstLogonCommands
部分,在 32 位 sysprep 之后完全可以正常工作。命令运行时没有任何错误,并返回所需的结果。
当我调整了 64 位安装的应答文件后,它看起来像这样:
<?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">
<DesktopOptimization>
<ShowWindowsStoreAppsOnTaskbar>false</ShowWindowsStoreAppsOnTaskbar>
</DesktopOptimization>
<CopyProfile>true</CopyProfile>
<DoNotCleanTaskBar>true</DoNotCleanTaskBar>
<EnableStartMenu>true</EnableStartMenu>
</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">
<FolderLocations>
<ProfilesDirectory>U:\Users</ProfilesDirectory>
</FolderLocations>
<FirstLogonCommands>
<SynchronousCommand wcm:action="add">
<CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -NonInteractive -ExecutionPolicy Bypass -File C:\Windows\System32\Scripts\PinTaskbarItems\Managetaskbar\Taskband.ps1</CommandLine>
<Description>Sets the pinned taskbar items and restarts the explorer process</Description>
<Order>1</Order>
<RequiresUserInput>false</RequiresUserInput>
</SynchronousCommand>
</FirstLogonCommands>
</component>
</settings>
<cpi:offlineImage cpi:source="wim:e:/sources/install.wim#Windows 10 Pro" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>
唯一反转的是密钥pass
的参数settings
。当我在 64 位安装 sysprep 上尝试此应答文件时,它FirstLogonCommands
没有运行。应答文件的其余部分运行正常,就像 32 位版本一样。
两个应答文件均经过 WSIM 验证。
我尝试将密钥中的行复制<CommandLine>
到 CMD(有或没有管理员权限)并运行此命令。运行此命令时,命令运行正常,没有任何错误。
问题是该脚本没有在我的 64 位安装 sysprep 上运行。
这是怎么发生的?我如何使用这个应答文件来运行这个脚本?