See all of the top support solutions for our most common issues here
One of the components of System Center Configuration Manager 2007 (SCCM 2007) Operating System Deployment (OSD) is boot images. Boot images in SCCM are really just WinPE images and are used during the operating system deployment process to boot computers so that an operating system can be loaded.
For more information about boot images and WinPE, see the following links:
What is Windows PE?
Planning for the Boot Image
Typically, the standard boot images included in SCCM will provide enough functionality needed to deploy an Operating System, (outside of possibly adding drivers). In some cases, it may be required for administrators to have a script or a command run when the boot image boots and WinPE is started. As an example, one customer, due to specific network restrictions, had to run a command when WinPE started so that a specific route could be added in order for the client to reach the server. The customer created a batch file to run the command and configured WinPE to execute it at every start time, before WinPE started the task sequencing process.
Out of the box, it is not very straightforward to add such customizations to your boot images, so the purpose of this article is to provide information on how to add a batch file or command so that it is executed when your boot image starts.
As a note, there was an article provided in TechNet which describes the process of modifying WinPE to add a script or batch file so that it would be executed when WinPE started. Unfortunately, in SCCM, when boot images are updated so that drivers can be injected or settings are modified, the update process is automated so there isn’t an opportunity to make other customizations. The article I am referring to is http://technet.microsoft.com/en-us/library/cc766521(WS.10).aspx, which provides three ways to add a command to WinPE. The first two methods, using Winpeshl.ini, or Startnet.cmd, don’t work in SCCM. The third method, creating an unattend.xml, will work fine.
This article describes how to create an unattend.xml so that specific commands or scripts can be executed every time your WinPE boot image starts.
The first thing you need to do is figure out if you need to run a command, batch file, or vbScript prior to WinPE executing. The unttend.xml is command based, and you can add multiple commands ordered in any way you like. If you have more than one command you want to run you can certainly add those to a batch file.
If you are going to reference a batch file create the file and copy it to the SCCM Site Server at: C:\Program Files\Windows AIK\Tools. In this example, I will name the batch file PrePE.cmd.
The easiest way to create an unattend.xml from scratch is to use System Image Manager. After you create your initial unattend.xml for use in this process, you may decide to edit the XML using notepad. Regardless, the below instructions will describe how to use Windows System Image Manager (SIM) to create an unattend.xml so that WinPE will execute a command or the PrePE.cmd file at WinPE startup.
1. Logon to your SCCM SP2 site server as the Windows System Image Manager utility will already be installed. Note: The reason it is already installed is because (SIM) is included in the WAIK which is installed with SCCM.
2. Open SIM by selecting Start – Programs - Microsoft Windows AIK – Windows System Image Manager.
3. In the SIM select File – Select Windows Image.
4. At the Select a Windows Image dialog, browse to the extracted contents of your Windows 7 DVD\Sources folder and select install_Windows 7 ULTIMATE.clg (Enterprise) and then click Open.
5. One an image catalog is selected, create a new answer file by selecting File – New Answer File.
6. Under the Windows Image section in the SIM, navigate to Components and right-click x86_Microsoft-Setup_6.1.x_neutral and in the context menu select Add Setting to Pass 1 windowsPE.
7. Now in the Answer File section of the SIM, you will see the component under windowsPE. Select x86_Microsoft-Windows-Setup_neutral and in the Properties pane, change the Enable Firewall value to True.
8. Right-click the RunSynchronous section and in the context menu, select Insert New RunSynchronousCommand. In the Properties section, verify the following Properties are set.
Action: AddListItem Description: Executes the PrePE.cmd Order: 1 Path: PrePE.cmd
9. Once all the Properties are added you can delete all of the sub-components which were not edited.
10. To save the answer file select File – Save Answer File As and save the file under C:\Program Files\Windows AIK\Tools as unattend.xml.
11. If you open the XML in notepad you can make modifications.
<?xml version="1.0" encoding="utf-8"?> <unattend xmlns="urn:schemas-microsoft-com:unattend"> <settings pass="windowsPE"> <component name="Microsoft-Windows-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <RunSynchronous> <RunSynchronousCommand wcm:action="add"> <Description>Executes the PrePE.cmd</Description> <Order>1</Order> <Path>PrePE.cmd</Path> </RunSynchronousCommand> </RunSynchronous> <EnableNetwork>true</EnableNetwork> </component> </settings> <cpi:offlineImage cpi:source="catalog://labcm1/osdeploy/ossource/windows7x86/sources/install_windows 7 ultimate.clg" xmlns:cpi="urn:schemas-microsoft-com:cpi" /> </unattend>
The following technique is an easy way to add files to your boot images without having to mount and unmount your boot.WIMs. For background purposes, every time you select “Update Distribution Points” for you boot images in SCCM, the boot image is mounted, files are injected, unmounted, and distribution points are updated. One of the files SCCM uses to identify files to add is the osdinjection.xml. You can edit this file to reference custom files you want included in your boot image.
1. On your SCCM site server, navigate to <SCCM Installation Folder>\bin\i386.
2. Make a backup copy of the file osdinjection.xml.
3. Edit the original osdinjection.xml in Notepad and under the following section:
<?xml version="1.0" encoding="utf-8"?> <InjectionFiles> <Architecture imgArch="i386"> <FileList source="WAIK">
Add the following:
<File name="unattend.xml"> <LocaleNeeded>false</LocaleNeeded> <Source>tools</Source> <Destination>windows\system32</Destination> </File> <File name="prePE.cmd"> <LocaleNeeded>false</LocaleNeeded> <Source>tools</Source> <Destination>windows\system32</Destination> </File>
Here is a sample:
4. As you can see, the two files we added to C:\Program Files\Windows AIK\Tools, unattend.xml and PrePE.cmd are referenced, and will be copied to the Windows\System32 folder in WinPE.
5. So that the files are also executed in the 64-bit boot image, find the section:
<Architecture imgArch="x64"> <FileList source="WAIK">
6. Save the osdinjection.xml file.
7. In Configuration Manager 2007, navigate to Site Database / Computer Management / Operating System Deployment / Boot Images and right-click your boot image and select “Update Distribution Points”. The boot images will be recompiled and sent to distribution points.
You can test the boot image right away if you are using PXE Boot or use the Create Task Sequence Media and create boot media. The next time the boot image boots, the batch file PrePE.cmd will run prior to the Task Sequence engine kicks off.
Gerry Borger | Senior System Center Support Engineer
The App-V Team blog: http://blogs.technet.com/appv/ The WSUS Support Team blog: http://blogs.technet.com/sus/ The SCMDM Support Team blog: http://blogs.technet.com/mdm/ The ConfigMgr Support Team blog: http://blogs.technet.com/configurationmgr/ The OpsMgr Support Team blog: http://blogs.technet.com/operationsmgr/ The SCVMM Team blog: http://blogs.technet.com/scvmm/ The MED-V Team blog: http://blogs.technet.com/medv/ The DPM Team blog: http://blogs.technet.com/dpm/ The OOB Support Team blog: http://blogs.technet.com/oob/ The Opalis Team blog: http://blogs.technet.com/opalis