Windows PE autorun scripts

Solution 1:

Under the "sources" folder on the PE key is the "boot.wim" file.

Mount Boot WIM:
dism /Mount-Wim /wimfile:C:[WPE PATH]\sources\boot.wim /index:1 /MountDir:C:\Mounted_images\boot

Then the file can be found at:
C:\Mounted_images\boot\Windows\System32\startnet.cmd


Commit changes and Unmount WIM:
dism /Unmount-Wim /MountDir:C:\Mounted_images\boot /commit

If you want to discard changes instead:
dism /Unmount-Wim /MountDir:C:\Mounted_images\boot /discard

Solution 2:

Generally I don't do autorun scripts for fear that someone would accidentally wipe their machine. The solution I found worked well was to provide a single batch file with a simple name, and tell them to type that at the command-prompt and press return. If you have multiple images for different makes/models you could call it a name based on the made model, e.g. type "dellgx280" to re-image a Dell GX280.

You can however modify the startnet.cmd file (WinPE's equivalent of autoexec.bat) to do it if you really want. That just a case of mounting the PE image r/w, locating the file (at %systemroot%\system32), editing it, then commiting and unmounting.

Solution 3:

In addition to the great answer by @nick-phipps, I recommend the Dism++ tool for easy handling (i.e. mounting) of the WIM image in order to edit the "autoexec.bat" file at C:\Mounted_images\boot\Windows\System32\startnet.cmd