Automating Windows Installs from .imgPTN files
WARNING: If you add an XML file which automatically partitions and formats a drive, then as soon as you UEFI-boot, it will destroy the disk contents of any system you connect it to. In particular, if you UEFI-boot from a .imgPTN file there will be no menu or other warning at all! Be careful that you don't just pick up an E2B USB drive in this state and just UEFI-boot from it - it may wipe your system disk!I highly recommend using the Auto.cmd method #3. below, to avoid this problem (or use an Image Index value of 99 so that you are required to press a key)!
You can find details on the SDI_choco feature of E2B here (for automatic driver, application install and Windows Updates).
How Windows Install .imgPTN file work:
- Setup.exe automatically loads the XML file or the XML file path was specified
- XML file tells WinPE to run \e2b\stage1.cmd which copies stage2.cmd and other files to the C: drive
- On reboot, stage2.cmd is run and it switches the partition back to the E2B partition.
- stage2.cmd also contains the name of the CONFIGURATION SET script - e.g. set CONFIG=fred.cmd
- \_ISO\WINDOWS\INSTALLS\CONFIGS\fred.cmd is run and copies the files from \_ISO\WINDOWS\INSTALLS\CONFIGS\FRED\ folder to C: drive
- Execution now continues using the files which were copied to the C: drive.
To use a different configuration set - e.g. FRED, you need to:
- Ensure the XML file contains an entry to run \e2b\stage1.cmd
- Ensure the \e2b\stage2.cmd file has the CONFIG variable set to FRED.cmd (set CONFIG=FRED.cmd)
- Ensure \_ISO\WINDOWS\INSTALLS\CONFIGS\FRED.cmd exists (a copy of SDI_CHOCO.cmd)
- Ensure the folder \_ISO\WINDOWS\INSTALLS\CONFIGS\FRED\ exists (copy of SDI_CHOCO folder)
- Create\Modify the mystartup.cmd and any other myxxxx.cmd files you require in the \_ISO\WINDOWS\INSTALLS\CONFIGS\FRED\ folder (use Sample_myxxx.cmd files as template).
Method 1. If your E2B USB drive is a Removable Flash drive
Method 2. If your E2B USB drive is NOT a Removable Flash drive
Note: recent versions of Windows 10 (e.g. 1803+) will detect a \AutoUnattend.xml file in the root of a 'Fixed-disk' type of USB drive. So try Method 1 first as it is easier!
Note: MPI 0.068+ - if you boot to the CSM Menu (MBR mode), the CSM menu will copy the contents of the \AutoUnattend.xml file to the \AutoUnattend.xml file on your WinHelper USB drive. So all you need to do is place the \AutoUnattend.xml file in your .imgPTN partition and connect a WinHelper USB drive. If you want to UEFI-boot however, you must first boot to the CSM menu (do NOT use a VM), or ensure that the correct \AutoUnattend.xml file is on the WinHelper drive.WARNING: Note that if you UEFI-boot from the E2B drive in this state (switched to .imgPTN partition) on ANY UEFI-system, there will be no warning whatsoever and the target hard disk will immediately be wiped and formatted, if your XML is set up to do this!
Method 3. Easy to change AutoUnattend.xml (select from a number of different XML files)
This process is a bit more complicated than Method 2 above, but it allows you to easily change the \AutoUnattend.xml file which is located in the root of the image (i.e. it is not inside the \sources\boot.wim file) or we can even allow the user to select from a range of XML files.
This method causes Windows Setup to search for \auto.cmd and run it. This allows us specify any XML file we like.
This method was tested using a Murphys AIO - Win7SP1_5in1-x86-Aug2015-en-US.iso (Size: 3.57 GB SHA-1: 4DA0D82FDF22222BB018C61EA5DB743EC7974AA8).
1. Mount the boot.wim file as in method 2 above using GimageX (make sure you select the Setup image - usually #2 - inside the boot.wim file)
2. Copy in the winpeshl.ini and mysetup.cmd file to the windows\system32 folder of the mounted boot.wim image - e.g. F:\mount1\windows\system32
The download for these files is here. It is best to copy the \sources\boot.wim file to your Windows hard disk before you mount it, then modify it and delete the one on the USB drive and replace it with the new one.3. Commit the changes and Unmount boot.wim (close ALL Explorer windows first or you may get an error!)
Note: if you have problems with unmounting the boot.wim, check it is not corrupt by remounting it and ensure that the new files are still present. You may need to make a new Mount folder (e.g. \mount2) or reboot your Windows system before it will remount - it is quite temperamental and does not always work after a few times!
4. Copy the Auto.cmd file and your AutoUnattend.xml file to the root of your E2B USB drive (that is the image partition which should have \sources folder and \boot folder)
We now need to add\change XML files(s) and edit the auto.cmd file...
E2B .imgPTN partition
\AutoUnattend.xml
\Auto.cmd
\Sources\boot.wim <<< contains winpeshl.ini and mysetup.cmd in the \windows\system32 folder.
You can now edit or replace the sample \AutoUnattend.xml as desired.
X:\Windows\Panther\Setupact. Tip: in case of trouble, look in the log file log for 'Logging new OS to BB' and the next few lines after that - it should report a AutoUnattend.xml file was found. If not then look in X:\Windows\Setupact.log.
You can even prompt the user (using auto.cmd) and ask them which one of several unattend.xml files they want to use if you change the script in the \Auto.cmd file.
I highly recommend using a auto.cmd file to prompt the user, even if you only have one XML file, because it also prevents you from accidentally booting from the USB drive and immediately wiping the system's internal hard disk without warning!
Each xml file can have different Product Keys and other settings.
E2B .imgPTN partition
=============
\AutoUnattend.xml (to be edited)
\AutoUnattendP.xml (not supplied)
\AutoUnattendBlank.xml (can be used for normal install)
\Auto.cmd (modified as below)
\Sources\boot.wim <<< contains new winpeshl.ini and mysetup.cmd in the \windows\system32 folder
\Auto.cmd (replace the contents of Auto.cmd with these lines)
Here is one method:AutoUnattend.cmd, AutoUnattendP.cmd and AutoUnattendBlank.cmd should have different CONFIG values and be located in the \e2b folder.
if not exist %UNAT%\e2b\Auto.cmd echo Could not find Auto.cmd & pause & exit@echo off
color 1f
FOR %%i IN (C D E F G H I J K L N M O P Q R S T U V W X Y Z) DO IF EXIST %%i:\Auto.cmd set UNAT=%%i:
if not exist %UNAT%\Auto.cmd echo ERROR: Could not find Auto.cmd & pause & exit:loop
cls
echo.
echo Choose an option
echo.
echo 1 Install Windows 8.1 Core
echo 2 Install Windows 8.1 Professional
echo 3 Choose later and enter the Product Key manually
echo.
set ask=
set XML=
set /p ask=Please choose :
if "%ask%"=="" goto :loop
if "%ask%"=="1" set XML=AutoUnattend
if "%ask%"=="2" set XML=AutoUnattendP
if "%ask%"=="3" set XML=AutoUnattendBlank
if "%XML%"=="" goto :loopif not exist %UNAT%\e2b\%XML%.cmd echo ERROR: %UNAT%\e2b\%XML%.cmd does not exist! & pause
copy %UNAT%\e2b\%XML%.cmd %UNAT%\e2b\stage2.cmdx:\setup.exe /unattend:%UNAT%\%XML%.xml
exit
@echo off
color 1f
FOR %%i IN (C D E F G H I J K L N M O P Q R S T U V W X Y Z) DO IF EXIST %%i:\Auto.cmd set UNAT=%%i:
if not exist %UNAT%\Auto.cmd echo Could not find Auto.cmd & pause & exit
if exist %UNAT%\e2b\MyConfig.cmd del %UNAT%\e2b\MyConfig.cmd > nul
:loop
cls
echo.
echo Choose an option
echo.
echo 1. Customer - No Office
echo 2. Customer - Office 2013
echo 3. Customer - Office 2016
echo 4. Customer - All apps
echo 5. Home - Own
echo 6. Home - Kids
echo 7. Home - MMServer
echo.
set ask=
set XML=
set /p ask=Please choose :
if "%ask%"=="" goto :loop
if "%ask%"=="1" set XML=ProCustomer.xml
if "%ask%"=="2" set XML=ProCustomer.xml
if "%ask%"=="3" set XML=ProCustomer.xml
if "%ask%"=="4" set XML=ProCustomer.xml
if "%ask%"=="5" set XML=Home.xml
if "%ask%"=="6" set XML=Home.xml
if "%ask%"=="7" set XML=MMServer.xml
if "%XML%"=="" goto :loop
:: ensure stage2.cmd has name of the config file we want it to use
if "%ask%"=="1" echo set CONFIG=NoOffice.cmd> %UNAT%\MyConfig.cmd
if "%ask%"=="2" echo set CONFIG=Office2013.cmd> %UNAT%\MyConfig.cmd
if "%ask%"=="3" echo set CONFIG=Office2016.cmd> %UNAT%\MyConfig.cmd
if "%ask%"=="4" echo set CONFIG=AllApps.cmd> %UNAT%\MyConfig.cmd
if "%ask%"=="5" echo set CONFIG=Own.cmd> %UNAT%\MyConfig.cmd
if "%ask%"=="6" echo set CONFIG=Kids.cmd> %UNAT%\MyConfig.cmd
if "%ask%"=="7" echo set CONFIG=MMServer.cmd> %UNAT%\MyConfig.cmd
for /f "tokens=2* delims= " %%A in ('reg query HKLM\System\CurrentControlSet\Control /v PEFirmwareType') DO SET Firmware=%%B
:: Note: delims= is a TAB followed by a space.
if "%Firmware%"=="0x1" echo WinPE booted in BIOS mode.&& set BOOTMODE=MBR
if "%Firmware%"=="0x2" echo WinPE booted in UEFI mode.&& set BOOTMODE=UEFI
Modifying XML files
Use Split_WinISO.exe
Tip: Ensure there are no spaces or strange characters in the path or ISO name!
AIO ISOs
Tips on making an AutoUnattend.xml file
Editing the XML file without using XMLtoE2B
You will need to insert the red text twice, because the OSImage section occurs twice - once for 32-bit and once for 64-bit (amd64).
The Windows utility XMLtoE2B.exe will convert the output of the Windows Answer File Generator to the correct format for an automated install.
It is available on request, to anyone who has made a donation of £10 or more. I will include a licence file to make it fully functional.
If you want the user to be prompted to input their own ComputerName near the end of the installation, delete the
Fig.2 Delete completely the two ComputerName lines, if you want the end user to be prompted to enter a machine name (SkipMachineOOBE=false).
To enable the Administrator account, set the AutoLogon UserName to Administrator. If you do not add any User Accounts in the XML file, then you will be prompted to create a User Account at the end of the build unless you set SkipMachineOOBE to true.
Testing Automated Windows 8/8.1/10 MBR and UEFI installs using a Virtual Machine
When booting from an E2B USB drive on a real system, the Hard disk should be Drive 0.
Unfortunately, Virtual Box + DavidB's VMUB utility can only boot from the USB drive as Drive 0, so we need to make sure Windows is installed to Drive 1 not Drive 0 (and that the XML file does not wipe Drive 0).
Also, the E2B USB drive will be seen as a 'Fixed Disk' in VirtualBox (even if it is really a Removable Flash drive)
2. Edit the XML answer file using NotePad and change all occurences of DiskID
3. Using MakePartImage, convert your Windows 8/8.1/10 Install ISO to a FAT32 partition image using the MPI_FAT32 shortcut. Copy it to \_ISO\MAINMENU on the E2B Drive.
4. Boot to E2B (e.g. using DavidB's VMUB utiity) and run the Windows .imgPTN menu entry to get to the CSM menu - then exit (F10).
5. You should now see the contents of the .imgPTN partition on the E2B USB drive using Windows Explorer (e.g. \Sources folder)
6. Add the XML file to the root of the \Sources\boot.wim file as described above using GImageX (file must be called AutoUnattend.XML).
Note: if you want to be able to easily update the XML file in future or choose from a selection of XML files, refer to the '3. Easily changeable AutoUnattend.xml' heading on this page. For instance, you can have different XML files for Win8 Core, Win8 Pro, MBR and UEFI\GPT installs.
7. (optional) Boot to the E2B USB drive in MBR mode and switch back to the E2B menu. Then copy the .imgPTN file to your system hard drive - this is a backup file in case things go wrong!.
8. (optional) Boot to the E2B USB drive in MBR mode and select the .imgPTN file again. Quit at the CSM menu.
9. Now boot from the VM in UEFI mode or MBR\BIOS mode (32-bit or 64-bit) as required using DavidB's VMUB utility. The install should proceed automatically to the virtual disk 1.
UEFI VM - When the installation completes do not reboot (otherwise the Windows Install will start again and wipe Drive 1!). You can now check the install worked as expected within Windows.
10a. MBR VM - When Windows reboots, press F7 in the CSM menu to boot from the virtual hard disk.
10b. UEFI VM - If you want to boot again to Windows on Disk 1, run Virtual Box manager and delete the E2B USB .vmdk entry under Storage (e.g. SATA0) leaving just the Virtual Disk drive as disk 1 (SATA1 or IDE slave) as shown below. Now boot from the UEFI VM (do NOT use DavidB's VMUB utiity) and it will boot to Windows each time from the Virtual disk 1.
If you use DavidB' VMUB utility to boot from the E2B USB drive, it will add back in the USB drive (.vmdk) and then it will boot from the E2B USB drive again and a Windows Install will start again.
Boot it in MBR\Legacy mode to return back to the E2B Main menu (use CSM menu option 0) - or run the \e2b\Restore_e2b.cmd batch file from Windows or run \_ISO\SWITCH_E2B.exe and click on the 'Restore E2B partitions' button.