SPREAD THE WORD, TOGETHER WE HAVE CONQUERED SYSPREP
This is version 2 of a step by step guide on Sysprepping a Windows 7 machine from start to finish. I cannot take full credit on this because my first article had so many helpful comments and discussions that this is simply a combination of all the good advice written into a working guide. (I would especially like to thank George for his input on Cscript for auto activation and Nathan for input on Sysprep Audit Mode). This will guide you through the following:
- Audit Mode
- Building the unattend.xml file in WSIM
- copyprofile=true command to copy the default profile (no manual copy)
- Prompt for a computer name
- Enable Administrator account
- Administrator account logs in first time automatically
- Activate windows automatically with Cscript;
- Successfully copy over taskbar icons;
- Delete unattend.xml file automatically upon completion of re-image.
Here is a list of what you will need:
- Latest version of WAIK : KB3AIK_EN.iso Version 1.0
- Windows Vista or Windows 7 Machine to build the XML file on
- ISO or DVD of Windows 7 Installation (x32 or x64)
- WinPE Boot Environment : BrianLeeJackson WinPE 3.0 BootLoader
First we are going to walk through building the unattend.xml file (answer file) and then we will walk through the actual Windows 7 imaging process.
PART 1 – XML FILE CREATION
Step #1
If you have a Windows 7 installation DVD, insert it now. Or if you have an ISO of 7, go ahead and extract it to a folder on your desktop. (I recommend 7-zip).
Step #2
Launch Windows System Image Manager. Your start menu should look like the image below:
Step #3
Under the “Windows Image” header, right click and select new image.
Step #4
You will now want to browse to the .CLG file in your Windows 7 installation (I am using Windows 7 Enterprise x64 in my example). It is located in the sources folder. See Image below. You can select either the .clg file or the install.wim. Both will have the same result.
Step #5
Now we need to create a new answer file. Go to the file menu and select “Create New Answer File.” Right after creating one, go ahead and simply go to file menu and select “Save Answer File.” This will give your XML file a name and save location. I chose to name mine unattend.xml. Now you see we have two category folders, Components and Packages. Under the Components folder you see that we have 7 options:
-1 windowsPE
-2 offlineServicing
-3 generalize
-4 specialize
-5 auditSystem
-6 auditUser
-7 oobeSystem
Step #6
These are very important as these are the steps in which the unattend.xml file is sequenced.
The next part is a little confusing. You are going to add components, from under the “Windows Image” section on the bottom left hand side to the passes on your Answer File. To add a component, you can right click on them and select “add to # pass”. There are many different options you can add, but they have to be done in a certain order and pass otherwise your sysprep might fail. I am simply going to use the one I created as the example.
Here is more information about adding options under the passes:
1 windowsPE
Nothing required in my example.
2 offlineServicing
Nothing required in my example.
3 generalize
amd64_Microsoft-Windows-Security-SPP_6.1.7600.16385_neutral
Set 1 for SkipRearm to allow up to 8 rearms
4 specialize
amd64_Microsoft-Windows-Deployment_6.1.7600.16385_neutral
Order: 1
path: net user administrator /active:yes
WillReboot: NeverRunSynchronousCommand[Order="1"]
RunSynchronous
amd64_Microsoft-Windows-Security-SPP-UX_6.1.7600.16385_neutral
SkipAutoActivation: true
amd64_Microsoft-Windows-Shell-Setup_6.1.7600.16385_neutral
Computer Name: Leave blank (we will deal with this at the end)
CopyProfile: true
Registered Organization: Microsoft (you must leave this in this section)
Registered Owner: AutoBVT (you must leave this in this section)
ShowWindowsLive: false
TimeZone: Pacific Standard TimeYou can delete other sub-header components if you don’t need them.
5 auditSystem
Nothing required in my example.
6 auditUser
Nothing required in my example.
7 oobeSystem
amd64_Microsoft-Windows-International-Core_6.1.7600.16385_neutral
InputLocale: en-us
SystemLocale: en-us
UILanguage: en-us
UserLocale: en-usamd64_Microsoft-Windows-Shell-Setup_6.1.7600.16385_neutral
RegisteredOrganization: Your Company Name
RegisteredOwner: Your NameAutoLogon
Password: Administrator Password
Enabled: true
LogonCount: 5
Username: administratorFirstLogonCommands
CommandLine: cscript //b c:\windows\system32\slmgr.vbs /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX (windows 7 license key)
Order 1
RequiresUserInput: falseCommandLine: cscript //b c:\windows\system32\slmgr.vbs /ato
Order 2
RequiresUserInput: falseSynchronousCommand[Order="1"]
SynchronousCommand[Order="2"]
OOBE HideEULAPage: true
NetworkLocation: Home
ProtectYourPC: 1UserAccounts
Password: Administrator Password
Action: AddListItem
Description: Local Administrator
DisplayName: Administrator
Group: Administrators
Name: AdministratorLocalAccount[Name="Administrator"]
AdministratorPassword: Administrator Password
LocalAccounts
If you have questions, look at my image above to see full layout of components, it should help.
Step #7
K, now go ahead and save your answer file as unattend.xml.
Step #8
If you want the sysprep to prompt for a computer name you need to remove a line from your XML file. Open up your XML file you saved with notepad and remove the following line:

Unattend.xml Computer Name
PART 2 – IMAGING PROCESS / RUNNING SYSPREP
Step #9
Install Windows 7 (Enterprise) from CD or USB flash drive, when you arrive at the welcome screen and it asks you to create a username, hit ctrl+shift+f3.
This will reboot your machine and put your windows build in ‘audit’ mode.
Step #10
On reboot, you’ll automatically be logged in under the built-in Administrator account. A sysprep GUI box will appear, but you can close it and NOW begin to customize your profile.
Step #11
Install any software/drivers, make any profile customizations, etc.
If you need to reboot, the computer will boot you back into the Administrator account. You will be stuck in this audit mode until you run sysprep with the /oobe parameter. After doing so, sysprep will delete/clean up the Administrator account, but if you have copyprofile=true in your unattended answer file, it will copy the customized Admin account to the default profile before deleting it.
Step #12
On the PC you are going to be running sysprep on, you need to create a folder called scripts in this directory: %WINDIR%\Setup\. Now you are going to create a CMD file within the %WINDIR%\Setup\Scripts directory. Right click and make a new text file called SetupComplete.txt. Remove the .txt extension and replace that with .cmd. You now have a SetupComplete.cmd file which windows will read the first time it boots up from the sysprep. We need to place a script inside the CMD file. Edit the cmd file with notepad and insert this line: del /Q /F c:\windows\system32\sysprep\unattend.xml. This script will delete your unattend.xml file after it has been used. The unattend.xml file is also copied to the C:\Windows\Panther directory, so you will want to add a second line to the CMD file, del /Q /F c:\windows\panther\unattend.xml. If you have passwords or cd keys stored in that xml file you don’t have to worry about it being left on the computer.
UPDATE AS OF JUNE 16TH: Read my Taskbar Icons Tutorial before continuing.
Step #13
Once you have everything configured correctly, Copy or move your unattend.xml file to : C:\windows\system32\sysprep. Now to run sysprep, navigate to that sysprep folder, hold SHIFT and right click and select “Open New Command Windows Here”. Next, input the following commands:
sysprep /generalize /oobe /shutdown /unattend:unattend.xml
Step #14
Turn the computer back on and boot to WinPE 3.0 environment (USB stick or CD/DVD). You can use my BrianLeeJackson WinPE3.0 BootLoader to boot up from USB or CD and capture your image. Capture image and save image to network location.
A Dell 960 or GX755 is a good standard for capturing when you want a generic image for use with multiple systems. Might require injecting additional drivers for 3rd party brands, HP, etc. Most should work though right out of the box.
Step #15
On reboot, Windows will run out of the box, as the /oobe is intended. As long as you put your cd key into the unattend.xml file, windows will be activated automatically in the background, you will be automatically logged into the administrator account, and the unattend.xml file is deleted. You are now ready to use the computer or join it to the domain. Enjoy!
Tags: Software, sysprep, unattend, unattend.xml, Windows 7, WinPE 3.0







I’ve discovered this tutorial when my Windows 7 installation was ready to be imaged, so I completely skipped the ctrl-shift-f3 for audit mode.
This is probably the cause of the above problem. I will follow all the steps on the next W7 image…
It’s possible to configure sysprep to not delete the local administrator account, because I’d like to make some customization to this account too.
Bye
Good Morning
Im having the hardest time creating the image after step 15.
I have created the Bootable image.
I have created the Answer file.
I have installed windows 7 and in audit mode configured the machine.
After I have dropped the .xml file in the Sysprep folder and ran the command, the machine shutdown. I was able to boot the machine in the WINPE with the boot media we created, but I only get a command prompt and nothing happens… We have been stuck for over a week and any help would be greatly appreciated did I miss a step? Also I did joined the machine to the network in order to access files to install on the machine. Would this stop the process from working?
Any ideas how to register the computer name to ZEN before logging in. I have a bat file that I would like to run just before logging into the computer is there a way to do this in the unattend.xml or some way to do this?
[...] http://blog.brianleejackson.com/sysprep-a-windows-7-machine-–-start-to-finish-v2 [...]
Thank you so much. This works great. It was so wonderful to find 1 document with all of the info I needed. I have been racking my brain with stingy little tidbits of info in Microsoft KBs. This was just what I needed. As always you are extemely helpful and your documentation is very well done
I have followed the above tutorial but I am looking for a solution to not install a MAK key and just use the KMS. In the part about installing the slmgr.vbs -ipk can I skip this and just run the slmgr.vbs. -ato command . I currently dont have 25 kms clients nor 5 windows 2008 servers but this image will be enough to get me to 25 clients. I am also looking for a solution to just prompt for the computer name but then auto join the domain. Any help is greatly appreciated. Thanks in advance. I saw some of the scripts above about joining the domain but don’t understand which one to use or where I should put them.
WINDOWS CANNOT COMPLETE INSTALLATION PLEASE RESTART ERROR
i have used this step by step guide to help build and deploy to my corporate environment. i found that to run throuogh to completion i needed to remove machine from the domain prior to running the sysprep. however this time i got the “windows cannot complete installation ….” error and i was unable to procede only to be stuck in and infinite loop or restarts. even in safe mode etc same error. what i ahve found is that on the removal from domain and subsequent reboot the admin account that i ahve used to build and configure the image, the only active account on my machine has been disabled . my work around to this (im using version 10.0 menus may have changed in newer versions)
download hirens boot cd
http://www.hirensbootcd.net/download.html
boot to cdrom
select bootCD
option 3 Password & registry Tools
option 1 Active Password changer
let APC browse for your SAM database and let it activate you admin accoutnn and blank your password
save changes and reboot your machine to OS should run through as normal get to “configuring for first use” the point of normal failure but then go through.
hope this helps anyone
I am running into an issue. I have created my unattend.xml file exactly how it was created in the example (only I use 32bit instead of 64bit). After running through everything and running sysprep and turning the machine back on, it begins to run through the setup but gets an error here:
“Windows could not parse or process the unattend answer file for pass [specialize]. The settings specified in the answer file cannot be applied. The error was detected while processing settings for [Microsoft-Windows-Shell-Setup].”
All I have in my answer file for the Shell Setup is the following…
CopyProfile = true
RegisteredOrganization = Microsoft
RegisteredOwner = AutoBVT
ShowWindowsLive = false
TimeZone = Eastern Standard Time
What about this could be causing problems?
Alright it seems like the problem was the copyprofile portion of the specialize pass. If set to false, no problem. If set to true, I get that error that I just described. Any ideas why this is?
Hi
I managed to create an autounttend.xml which partition the HDD successfuly and boots into audit mode. Now the problem is i am in audit mode and i want to install the drivers unattended.
I created the driver installation file under audit user mode, with runsynchronous.
So in audit mode i run sysprep /audit /unattend:c:\unattend.xml
The system reboots and starts the driver installation but after a while it will prompt with error “cannot parse c:\windows\panther\unattend.xml” then it starts the looping….
Can someone PLEASe help to post a unattend.xml that can install the drivers in unattended mode?
When I input this command:
“Open New Command Windows Here”. Next, input the following commands:
sysprep /generalize /oobe /shutdown /unattend:unattend.xml
It does nothing
And I’ve done it step by step.
Any Idea? Anyone?
Johan says:
Your comment is awaiting moderation.
August 26, 2010 at 1:12 am
When I input this command:
“Open New Command Windows Here”. Next, input the following commands:
sysprep /generalize /oobe /shutdown /unattend:unattend.xml
It does nothing
And I’ve done it step by step.
Any Idea? Anyone?
When I input this command:
“Open New Command Windows Here”. Next, input the following commands:
sysprep /generalize /oobe /shutdown /unattend:unattend.xml
It does nothing
And I’ve done it step by step.
Any Idea? Anyone?
Thanks for the tips, saved me a lot of time.
Any ideas why after syspreping and uping the image I log into the same machine without downing the image, run sysprep and log in as administrator it creates a new profile called administrator.computername
why wouldn’t it just use the already active administrator profile?
I hate to have to drop the image i just upped everytime I sysprep my machine for imaging.