WindowsAutomationDeployment

https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/add-a-custom-script-to-windows-setup?view=windows-10#use-unattend-to-run-scripts

Use Unattend to run scripts

Create an Unattend.xml file with one of these settings to run during the Windows Setup process. This can be used with OEM product keys.

To run services or commands that can start at the same time, use RunAsynchronousCommands.

Some of these settings run in the user context, others run in the system context depending on the configuration pass.

Run a script after setup is complete (SetupComplete.cmd)

Order of operations

  1. After Windows is installed but before the logon screen appears, Windows Setup searches for the SetupComplete.cmd file in the %WINDIR%\Setup\Scripts\ directory.

  2. If a SetupComplete.cmd file is found, Windows Setup runs the script. Windows Setup logs the action in the C:\Windows\Panther\UnattendGC\Setupact.log file.

  3. On the deployment base image computer open Notepad and enter in the following lines:

del /Q /F c:\windows\system32\sysprep\unattend.xml  
del /Q /F c:\windows\panther\unattend.xml

These lines of code will delete the unattend.xml file from the computer once the Windows Setup is finished with them (this file is copied into the panther directory during setup hence the two lines)

  1. Save this file to the desktop called SetupComplete.cmd

  2. Now create a folder called Scripts in this directory: C:\Windows\Setup\ and drag this file into it (you may be prompted for Administrator authority).