Sysprep
![]() | This article is written like a review. |
Sysprep is Microsoft's System Preparation Utility for Windows operating system deployment. Originally introduced for use with Windows NT 4.0, Sysprep can prepare an operating system for disk cloning and prevent issues that arise when otherwise restoring a disk image captured from one Windows installation onto other computers.
Issues that may arise from disk cloning
- Invalid or missing mass storage drivers.
- Invalid hardware abstraction layer (HAL).
- Missing device drivers.
- Duplicate computer names on a network.
- Workstation recognization issues in a domain. This is due to the fact that a security identifier (SID) is used to identify an NT workstation.
- If you put a 10GB image on a 40GB hard drive the new drive will only use 10GB, wasting 30GB unless you use the ExtendOemPartition=1 in sysprep.inf.
Using Sysprep on Windows NT 4.0 through Windows Server 2003
- To run Sysprep, extract it from the deploy.cab file on the Windows installation CD or download the latest Deployment Tools update from Microsoft. Deployment tools are available for Windows NT 4.0, Windows 2000, Windows XP SP1 and SP2 and Windows Server 2003. It is also available as part of the OPK.
- Create a directory in the root of the system drive named Sysprep.
- Copy the sysprep.exe, setupcl.exe and factory.exe files to the newly created Sysprep directory.
- Use Setup Manager (setupmgr.exe) to create the unattended answer file for sysprep. Depending on the version of the deployment tools you are using, the default name of the answer file will either be sysprep.inf or unattended.txt. Save the file as Sysprep.inf and place it in the Sysprep directory at the root of the system drive.
- Launch sysprep.exe manually to use a GUI to configure sysprep options or run sysprep from the command-line. This will prepare Windows for the first-run Out-Of-Box-Experience (OOBE).
In Windows XP, the OOBE can be Windows Welcome or Mini-Setup.
Mini-Setup uses the entries provided in sysprep.inf as its answer file. Windows Welcome uses entries provided in winbom.ini as its answer file.
Consult the ref.chm and deploy.chm files, also included in deploy.cab or the Deployment Tools download, for additional information.
Using Sysprep with Windows Vista (RC1/2/Final)
Purpose
- Prepares an installed computer for sale (customer has to enter productkey etc..)
- Prepares an installed computer for imaging (an answer file can be used to automate the process)
The Basics
- Launching
Vista's Sysprep is best invoked from a command line prompt:
c:\windows\system32\sysprep.exe /generalize /oobe
This cleans ( /generalize) the computer from machine-specific information and prompts the user for various information ( /oobe)
- Specifying an answer file
If you want to automate the deployment process it's best to provide sysprep with an answer file. For sysprep to accept it, you must specify another parameter:
c:\windows\system32\sysprep.exe /generalize /oobe /unattend:c:\sysprep.xml
Creating a custom sysprep.xml
Microsoft recommends using the BDD 2007 Software for creating such an answer file. However, you can find many sample files on the net for a start. Basically the unattend.xml used to install Windows Vista can be used as a sample sysprep.xml. Just make sure that:
- the xml is correct and well-formed (use your favourite xml-editor)
- no empty elements are present (will cause misleading parse-errors)
Note that when providing an answer file (filename is not important), Vista's sysprep copies the file to C:\Windows\Panther\unattend.xml. Thus, your original file becomes unimportant and you can just delete it. Instead, changes you make during an automated process go into the Panther\unattend.xml. Vista's Setup program searches about seven locations for an unattend.xml or autounattend.xml file. One of it (the fourth or so) is the Panther\unattend.xml.
- A sample sysprep.xml might look like this (no warranty given)
<unattend xmlns="urn:schemas-microsoft-com:unattend" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"> <settings pass="specialize"> <component name="Microsoft-Windows-Shell-Setup" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" processorArchitecture="x86"> <ComputerName>JohnWayne</ComputerName> <ProductKey>AAAAA-AAAAA-AAAAA-AAAAA-AAAAA</ProductKey> <TimeZone>Central European Standard Time</TimeZone> </component> </settings> <settings pass="oobeSystem"> <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" processorArchitecture="x86"> <FirstLogonCommands> <SynchronousCommand wcm:action="add"> <Order>1</Order> <CommandLine>C:\runonce.cmd</CommandLine> <Description>RunOnce Command</Description> </SynchronousCommand> </FirstLogonCommands> </component> </settings> </unattend>
Traps
- If you forget to add /generalize to sysprep, your imaged machines will come up with an error at the bootloader, saying that winload.exe is corrupt or missing.
- If your xml is not correct, vista will complain, but not tell you exactly where the problem lies. Empty xml-elements will cause the same error message.
- If you specify the wrong product key in your answer file, sysprep will crash with a fatal error
- Do not try to change the content of c:\sysprep.xml after the image is downloaded. Instead, apply changes to c:\windows\panther\unattend.xml, where the original was copied..
- In Windows PE 2.0, to mount a network drive, say it exactly like this or it will fail:
net use S: \\Server\Share /user:Server\User Password
What you will need:
- A Windows PE 2.0 Bootable CD (to boot your computer with)
- ImageX.exe (to create and deploy images to other computers, runs only in Windows PE)
- A sample sysprep.xml (or Microsofts BDD 2007 provides a wizard)