Run A Custom Script During WIN PE Intialization

by [Published on 1 Dec. 2010 / Last Updated on 31 Oct. 2009]

This article explains how you can run a custom script during WINPE intialization.

You can run a custom script during the WINPE Initialization. To do so, please follow the steps outlined below:


  • Download and install WAIK from MS:
  • Go to Start > type "WIN PE Tools Command Prompt"
  • Execute the following commands:
  • Copype.cmd x86 C:\Winpe_x86
  • Mount the Windows PE Image using the ImageX command:
  • ImageX /MountRW C:\Winpe_x86\Winpe.WIM 1 C:\Winpe_X86\Mount
  • Go to C:\Winpe_x86\Mount\Windows\System32\
  • Edit the StartNet.CMD. Note: By default, this file ships with the WINPE.WIM Image. Put the commands or another script you want to run when the WINPE enters into Initialization mode.
  • Finally, unmount the Image with changes you made using the ImageX command:
  • ImageX /UnMount C:\Winpe_x86\Mount /Commit
  • Copy the changed WINPE.WIM file to the ISO directory by executing the following command:
  • Copy C:\Winpe_x86\Winpe.WIM C:\Winpe_x86\ISO\Sources\BOOT.WIM

That's it! C:\Winpe_x86\ISO\Sources\BOOT.WIM is the changed WIN PE Image.

See Also

The Author — Nirmal Sharma

Nirmal Sharma avatar

Nirmal Sharma is a MCSEx3, MCITP and was awarded the Microsoft MVP award in Directory Services and Windows Networking. He specializes in Microsoft Azure, Office 365, Directory Services, Failover Clusters, Hyper-V, PowerShell Scripting and System Center products. Nirmal has been involved with Microsoft Technologies since 1994. In his spare time, he likes to help others and share some of his knowledge by writing tips and articles on various sites and contributing to PowerShell-based Dynamic Packs for www.ITDynamicPacks.Net solutions.

Featured Links