0

I want to run a batch file during the windowsPE phase of an unattended Windows setup, and the autounattend.xml works fine as long as I launch the batch file from its path like this:

<RunSynchronousCommand wcm:action="add">
  <Description>StartUp script</Description>
  <Path>cmd.exe /k D:\startup.bat<Path>
  <Order>6</Order>
</RunSynchronousCommand>
2023-11-21 11:41:53,  Info  IBS Command 5: 0x00000000

2023-11-21 11:41:56, Info IBS Successfully executed command 'cmd.exe /k "D:\startup.bat"' (exit code 0x00000000) 2023-11-21 11:41:56, Info IBS STATUS: SUCCESS (0x00000000)

2023-11-21 11:41:56, Info IBS ==== executing user-specified asynchronous commands ==== 2023-11-21 11:41:56, Info IBS STATUS: SUCCESS (0x00000001)

2023-11-21 11:41:56, Info IBS ==== Applying shutdown settings ==== 2023-11-21 11:41:56, Info IBS No shutdown setting was specified 2023-11-21 11:41:56, Info IBS STATUS: SUCCESS (0x00000001)

2023-11-21 11:41:56, Info IBS Successfully applied WinPE bootstrap unattend settings


The drive letter can be different, and setup fails when it doesn't find D:\startup.bat

  • To search for the file, I found this script, and it works fine when I run it from a terminal, but fails when it's run from the answer file:
      <RunSynchronousCommand wcm:action="add">
        <Description>StartUp script</Description>
        <Path>cmd.exe /k "(FOR %i IN (C D E F G H I J K L N M) DO IF EXIST %i:\startup.bat start %i:\startup.bat)"</Path>
        <Order>6</Order>
      </RunSynchronousCommand>
    </RunSynchronous>
    

I have tried dozens of variations:
using quotes, with/out parenthesis, echo instead of start, cmd without .exe, /c or /k, using &&, and creating a variable with SET and calling it via %var%

  • Setup always fails due to an error within the windowsPE Pass 1 of the answer file, and I can't figure out why:
    2023-11-21 11:25:21,  Info  IBS Command 5: 0x00000000
    

    2023-11-21 11:27:22, Info IBS Successfully executed command 'cmd.exe /k "FOR %i IN (C D E F G H I J K L N M) DO IF EXIST %i:\startup.bat start %i:\startup.bat"' (exit code 0xc000013a) 2023-11-21 11:27:22, Info IBS STATUS: FAILURE (0xc000013a)

    2023-11-21 11:27:22, Info IBS ==== executing user-specified asynchronous commands ==== 2023-11-21 11:27:22, Info IBS STATUS: SUCCESS (0x00000001)

    2023-11-21 11:27:22, Info IBS ==== Applying shutdown settings ==== 2023-11-21 11:27:22, Info IBS No shutdown setting was specified 2023-11-21 11:27:22, Info IBS STATUS: SUCCESS (0x00000001)

    2023-11-21 11:27:22, Error [0x0604a8] IBS Failed applying WinPE bootstrap unattend settings with status 0xc000013a

    2023-11-21 11:27:22, Info [0x0640ae] IBSLIB PublishMessage: Publishing message [The Windows PE bootstrap setting specified in the automatic response file could not be applied.]

JW0914
  • 9,096

1 Answers1

0

I ended up solving it by putting the batch file inside the WindowsPE image that launches windows setup (boot.wim). That way the file is always in the X:\ drive and I can just launch it from the answer file with "cmd.exe /k X:\Windows\Setup\startup.bat"