Automated windows install from an ISO

3 min read 25-10-2024
Automated windows install from an ISO

Automating Windows installations can save significant time and effort, especially in environments requiring multiple setups. This guide will walk you through the process of automating a Windows installation using an ISO file, making the task efficient and reproducible.

Understanding the Problem

You want to set up Windows automatically without having to manually configure settings during installation. The solution involves creating an unattended installation that utilizes an ISO image of the Windows operating system.

Original Code Example

Here is a simplified example code that shows how you might script an unattended installation using PowerShell (this is for illustrative purposes only; actual configurations may vary):

$ISOPath = "C:\path\to\your\windows.iso"
$Destination = "C:\path\to\extracted\files"

# Mount the ISO
Mount-DiskImage -ImagePath $ISOPath

# Copy files to destination
Copy-Item -Path "E:\*" -Destination $Destination -Recurse

# Dismount the ISO
Dismount-DiskImage -ImagePath $ISOPath

Steps to Automate Windows Installation from an ISO

1. Prepare the Environment

Before proceeding, ensure you have the following:

  • A valid Windows ISO file.
  • A USB drive (if installing on a physical machine) or a virtual machine setup (if using a VM).
  • Windows Assessment and Deployment Kit (ADK) installed on your system.

2. Create an Unattend File

An unattended installation requires an XML file that contains configuration settings. This file, typically named autounattend.xml, should be placed in the root directory of your Windows installation media (either on the USB drive or inside the ISO).

You can create the XML file using Windows System Image Manager (WSIM), which is part of the Windows ADK. Here’s a basic example of what your autounattend.xml might look like:

<?xml version="1.0" encoding="UTF-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
    <settings pass="windowsPE">
        <component name="Microsoft-Windows-Setup" processorArchitecture="amd64" version="10.0.19041" />
    </settings>
    <settings pass="generalize">
        <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" version="10.0.19041" />
    </settings>
    <settings pass="specialize">
        <component name="Microsoft-Windows-Security-Features" processorArchitecture="amd64" version="10.0.19041">
            <UserAccounts>
                <AdministratorPassword>
                    <Value>MyPassword123!</Value>
                    <PlainText>true</PlainText>
                </AdministratorPassword>
            </UserAccounts>
        </component>
    </settings>
    <settings pass="oobeSystem">
        <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" version="10.0.19041">
            <FirstLogonCommands>
                <SynchronousCommand wcm:action="add">
                    <Description>Run first logon commands</Description>
                    <Order>1</Order>
                    <Path>cmd.exe /c start /wait myapp.cmd</Path>
                </SynchronousCommand>
            </FirstLogonCommands>
        </component>
    </settings>
</unattend>

3. Prepare the Installation Media

  • USB Drive: Use tools like Rufus to create bootable USB media with the ISO. Ensure that your autounattend.xml file is placed in the root directory of the USB.
  • Virtual Machine: If you are using a virtual machine, you can load the ISO directly into the VM settings, ensuring that the autounattend.xml is accessible.

4. Boot and Install

Insert your bootable USB into the target machine or launch your virtual machine. Upon booting, the installer will read the autounattend.xml file and proceed with the installation without any user intervention.

5. Post-Installation

After the installation, verify the settings and applications defined in your unattended file. Additionally, check for any updates required post-installation to ensure the system is fully functional.

Additional Resources

Conclusion

Automating your Windows installations using an ISO and an unattended configuration can greatly enhance efficiency, particularly for system administrators and developers managing multiple installations. By following the outlined steps, you'll save time while ensuring a consistent setup across devices.

Feel free to explore additional options and settings within the unattend file to tailor the installation process to your specific requirements. Happy installing!