![autounattend.xml ファイル内のインストール メディアからスクリプトを実行する方法は?](https://rvso.com/image/1618751/autounattend.xml%20%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E5%86%85%E3%81%AE%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB%20%E3%83%A1%E3%83%87%E3%82%A3%E3%82%A2%E3%81%8B%E3%82%89%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%97%E3%83%88%E3%82%92%E5%AE%9F%E8%A1%8C%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95%E3%81%AF%3F.png)
PowerShell (.ps1) およびバッチ (.bat) スクリプトをいくつか作成し、それを自動化された Windows インストールの一部にしたいと考えています。Windows システム イメージ マネージャーを使用して、autounattend.xml ファイル内の他のすべてを既に構成しており、スクリプトの実行以外は完全に正常に動作しています。
完全に自動化しようとする前は、OOBE をバイパスして監査モード (CTRL+SHIFT+F3) に入り、そこからスクリプトを実行していました。スクリプトが監査モードで動作することはわかっていたので、Windows システム イメージ マネージャー内で、Pass 6 Audituser に同期コマンドを挿入することにしました。
これは今のところ私のautouattend.xmlファイルです
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<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">
<AutoLogon>
<Password>
<Value>cABhAHMAcwB3AG8AcgBkAFAAYQBzAHMAdwBvAHIAZAA=</Value>
<PlainText>false</PlainText>
</Password>
<Enabled>true</Enabled>
<LogonCount>3</LogonCount>
<Username>LocalAdmin</Username>
</AutoLogon>
<UserAccounts>
<LocalAccounts>
<LocalAccount wcm:action="add">
<Password>
<Value>cABhAHMAcwB3AG8AcgBkAFAAYQBzAHMAdwBvAHIAZAA=</Value>
<PlainText>false</PlainText>
</Password>
<Name>LocalAdmin</Name>
<Group>Administrators</Group>
<DisplayName></DisplayName>
<Description>Local adminstrator stored on the system drive</Description>
</LocalAccount>
</LocalAccounts>
</UserAccounts>
<OOBE>
<SkipMachineOOBE>true</SkipMachineOOBE>
<SkipUserOOBE>true</SkipUserOOBE>
<HideOnlineAccountScreens>true</HideOnlineAccountScreens>
<HideEULAPage>true</HideEULAPage>
</OOBE>
</component>
</settings>
<settings pass="windowsPE">
<component name="Microsoft-Windows-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">
<EnableNetwork>false</EnableNetwork>
<DiskConfiguration>
<Disk wcm:action="add">
<CreatePartitions>
<CreatePartition wcm:action="add">
<Order>1</Order>
<Size>500</Size>
<Type>Primary</Type>
</CreatePartition>
<CreatePartition wcm:action="add">
<Order>2</Order>
<Type>EFI</Type>
<Size>100</Size>
</CreatePartition>
<CreatePartition wcm:action="add">
<Order>4</Order>
<Extend>true</Extend>
<Type>Primary</Type>
</CreatePartition>
<CreatePartition wcm:action="add">
<Order>3</Order>
<Size>16</Size>
<Type>MSR</Type>
</CreatePartition>
</CreatePartitions>
<ModifyPartitions>
<ModifyPartition wcm:action="add">
<Format>NTFS</Format>
<Label></Label>
<Order>1</Order>
<PartitionID>1</PartitionID>
<TypeID>DE94BBA4-06D1-4D40-A16A-BFD50179D6AC</TypeID>
</ModifyPartition>
<ModifyPartition wcm:action="add">
<Order>2</Order>
<Format>FAT32</Format>
<PartitionID>2</PartitionID>
<Label>System</Label>
</ModifyPartition>
<ModifyPartition wcm:action="add">
<PartitionID>3</PartitionID>
<Order>3</Order>
</ModifyPartition>
<ModifyPartition wcm:action="add">
<PartitionID>4</PartitionID>
<Order>4</Order>
<Format>NTFS</Format>
</ModifyPartition>
</ModifyPartitions>
<WillWipeDisk>true</WillWipeDisk>
<DiskID>0</DiskID>
</Disk>
</DiskConfiguration>
<ImageInstall>
<OSImage>
<InstallTo>
<DiskID>0</DiskID>
<PartitionID>4</PartitionID>
</InstallTo>
<InstallFrom>
<MetaData wcm:action="add">
<Key>/IMAGE/NAME</Key>
<Value>Windows 10 Pro</Value>
</MetaData>
</InstallFrom>
</OSImage>
</ImageInstall>
<UserData>
<ProductKey>
<WillShowUI>OnError</WillShowUI>
<Key />
</ProductKey>
<AcceptEula>true</AcceptEula>
</UserData>
</component>
<component name="Microsoft-Windows-International-Core-WinPE" 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">
<SetupUILanguage>
<UILanguage>en-gb</UILanguage>
</SetupUILanguage>
<InputLocale>en-gb</InputLocale>
<SystemLocale>en-gb</SystemLocale>
<UILanguageFallback>en-us</UILanguageFallback>
<UILanguage>en-gb</UILanguage>
</component>
</settings>
<settings pass="auditUser">
<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">
<RunSynchronous>
<RunSynchronousCommand wcm:action="add">
<Order>2</Order>
<Path>powershell.exe -executionpolicy remotesigned -File "Files\Scripts\2A-Create_Daily_System_Restore_Point.ps1"</Path>
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">
<Description>Remove Windows Bloatware Provisioned Apps</Description>
<Order>1</Order>
<Path>powershell.exe -executionpolicy remotesigned -File "%~dp0\Files\Scripts\1-Remove_Bloatware_Apps.ps1"</Path>
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">
<Order>3</Order>
<Path>cmd.exe /c %~dp0\Files\Scripts\3-Remove_Folders_from_This_PC.bat</Path>
</RunSynchronousCommand>
</RunSynchronous>
</component>
</settings>
<cpi:offlineImage cpi:source="wim:d:/users/will/documents/it%20projects/windows%2010%20image/install.wim#Windows 10 Home" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>
Windows インストール メディアのルートに「Scripts」というディレクトリを配置する予定なので、質問ですが、インストール メディアから autounattend.xml 内のこれらのスクリプトをどのように呼び出すのでしょうか。インストール メディアがあるドライブとパスにリンクする変数はありますか。
答え1
解決策を見つけたと思います。
- ISO/Windowsインストールメディアをフォルダに抽出する
sources\
抽出したインストールメディアのディレクトリ内に、$OEM$- システムドライブをミラーリングして、次のパスのディレクトリを作成します。
sources\$OEM$\$$\Setup\Scripts
(C:\Windows\Setup\Scripts)
$OEM$フォルダはシステムドライブをミラーリングするため、これらのフォルダ内のものはすべてセットアップ中にコピーされます。autounattend.xmlファイルから実行されるスクリプトに関しては、次のスクリプトを呼び出すだけです。%SystemDrive%\WinDir\Setup\Scripts
詳細はこちらをご覧ください >https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-8.1-and-8/hh825027%28v%3dwin.10%29
答え2
私の知る限り、auditUser
システムが監査モードになっていない限り、Windows のインストール中にパスは実行されません。したがって、あなたの解決策の他に、他に 2 つの解決策があります。
- コマンドを
specialize
pass またはoobeSystem
pass に入力します。通常、インストール メディアには文字が割り当てられますX:
が、セットアップでスクリプトを確実に見つけられるようにするには、次のような条件を使用できます。
<RunSynchronousCommand wcm:action="add">
<Description>Run script</Description>
<Order>1</Order>
<!-- Enumerate through all drives looking for the MYIT_OEMBypass.ps1 script, if found, run it. Leave the command prompt open. -->
<Path>cmd /c "(FOR %i IN (C D E F G H I J K L N M) DO IF EXIST %i:\MYIT_OEMBypass.ps1 Powershell -executionpolicy ByPass %i:\MYIT_OEMBypass.ps1) & pause"</Path>
</RunSynchronousCommand>
oobeSystem
次のように入力して、パスの実行が開始されたときに Windows セットアップが監査モード (sysprep) に直接進むように指示します。
<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">
<Reseal>
<Mode>Audit</Mode>
<ForceShutdownNow>false</ForceShutdownNow>
</Reseal>
</component>
この方法を使用すると、維持できるコマンドはauditUser
パス時に実行されます。これにより、すべてのお気に入りの調整を含むデフォルト プロファイルを設定することもできます。これにより、後で作成されるプロファイルにも、それらの調整がすべて適用されます。
しかし、デフォルトでは、自動車unattend.xmlがコピーされ、sysprepのunattend.xmlスクリプトとして設定され、明らかに問題を引き起こします。そのため、sysprepに次のスクリプトを使用するように指示するために、いくつかの小さな変更を加える必要があります。違うunattend.xml。この方法の詳細なガイドについては、以下を参照してください。 https://rzander.azurewebsites.net/modern-os-deployment-mosd/