Pre Windows Setup Script/UI execution


gabrielgbs97

New member
Local time
9:31 AM
Posts
1
OS
Windows 11
I usually install Windows reference image using Autounattend.xml using Microsoft ISO with slightly custom image (i added languages and removed appxs offline). I had no problems so far, process is fast, simple and 100% unattended.

We come from MDT experience and we would like to execute a Powershell UI or script/bat to ask for confirmation before setup.exe wipes disk and installs fresh image. The main problem is that WinPE executes directly if setup.exe if it's present. How would be correct way to do it?

On top of that, I would enrich the installation process and execute setup.exe with aribtrary Autounattend*.xml file. This way the technician could choose installation variants.
 
Windows Build/Version
Windows 11 25H2

My Computer My Computer

At a glance

Windows 11
OS
Windows 11
What you're asking for cannot be done using the unattended file. Setup.exe is the program executing the unattended file's actions in the winPE pass. So it's already running by the time you get there.

Instead you need to interrupt the WinPE workflow, and insert a CMD script to launch your wrapper scripts before calling Setup.exe to actually start the real install. PowerShell isn't natively provided in WinPE. You would have to download the Windows ADK and the ADK WinPE Add-on's to apply the right Optional Components (or updates) to your boot.wim.

Download the ADK 10.1.26100.2454 (December 2024)
WinPE: Adding Windows PowerShell support to Windows PE

Obviously, a CMD script is faster if you want to get started without learning how to add PS (via the ADK).

Typically you can edit winpeshl.ini and execute a wrapper script or scripts. Like feeding diskpart a commands script. Afterwards you can call setup.exe using an explicit option for a specific answer file. The problems usually are trying to figure which drive letter your USB drive is mounted on.

Winpeshl.ini Reference: Launching an app when WinPE starts

Code:
@echo off
wpeinit

for %%A in (D E F G H I J K L M N O P Q R S T U V W Y Z) do if exist %%A:\sources\setup.exe (
    set DRIVE=%%A
    goto :continue
)

:continue

if exist %DRIVE%:\format-UEFI.txt (diskpart /s %DRIVE%:\format-UEFI.txt)
X:\sources\setup.exe /unattend:%DRIVE%:\unattend123.xml

The hard-core OSD community tend to have a lot of pre-made scripts which do these types of functions. So you're better off looking at them, rather than ElevenForum which is more a Windows enthusiast forum.
 

My Computer My Computer

At a glance

Windows 7
OS
Windows 7
Back
Top Bottom