Sysprep a Windows 7 Machine – Start to Finish V2

windows7sysprep

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).

Last Updated on 03.10.13

Proud to announce, this tutorial has been translated to Serbo-Croatian language by WHGeeks

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:

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.

sysprep4

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: Never
RunSynchronousCommand[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 Time

(Please view TimeZone settings here -> http://technet.microsoft.com/en-us/library/cc749073%28WS.10%29.aspx)

You 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-us

amd64_Microsoft-Windows-Shell-Setup_6.1.7600.16385_neutral

RegisteredOrganization: Your Company Name
RegisteredOwner: Your Name

AutoLogon
    1. Password: Administrator Password
  Enabled: true
  LogonCount: 5
  Username: administrator

FirstLogonCommands

     1. CommandLine: cscript /b c:\windows\system32\slmgr.vbs /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX (windows 7 license key)
     Order 1
     RequiresUserInput: false
     CommandLine: cscript /b c:\windows\system32\slmgr.vbs /ato
     Order 2
     RequiresUserInput: false

   SynchronousCommand[Order="1"]

   SynchronousCommand[Order="2"]

OOBE
  HideEULAPage: true
  NetworkLocation: Home
  ProtectYourPC: 1

UserAccounts
     1. Password: Administrator Password

   Action: AddListItem
   Description: Local Administrator
   DisplayName: Administrator
   Group: Administrators
   Name: Administrator

  LocalAccount[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:

sysprep5

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 FEBRUARY 27, 2013: 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 you need to launch Command Prompt as an administrator. To do this press start, and type into the search CMD then right click on CMD and select run as Administrator. Next navigate to the sysprep folder by typing: cd sysprep and pressing enter.

cd-sysprep

Next, input the following commands:

sysprep /generalize /oobe /unattend:unattend.xml /shutdown

Step 14

Turn the computer back on and boot to WinPE 3.0 environment (USB stick or CD/DVD). You can use our TheITBros WinPE3.1 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!

TIP #1

Thanks T800 for the tip: “Apparently I had to stop ‘Windows Media Player Network Sharing’ service before I could run /oobe /generalize, otherwise it gave me a fatal error.”
Dan Wright also mentioned that you need to set the network location to “Public” and/or delete some files and registry keys. See this article: http://technet.microsoft.com/en-us/library/ee676648(v=ws.10).aspx

TIP #2

To enable Aero your computer needs to calculate it’s performance score. Do you want to do that on each and every machine? No. So, if all machines have the same hardware, run this before syspreping your master-image :

winsat prepop

This will calculate the performance index and put it on your machine in xml-format. If the OOBE wizard finds this xml file, and the hardware hasn’t changed, it uses the pre-populate values and Aero works out of the box.

TIP #3

From user comment:
After many hours of battling, I also found that a registry entry must be added for sysprep to look in the C:\Drivers location. In HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/Current Version click on “DevicePath” and enter “C:\Drivers” (remember the entries must be separated by a semicolon). More info here: http://technet.microsoft.com/en-us/library/cc753716.aspx

TIP #4

From user comment:
To keep the drivers installed to the computer there has to be a option under “generalize” (Microsoft-Windows-PnpSysprep_neutral -> PersistAllDeviceInstalls=TRUE and DoNotCleanUpNonPresentDevices=TRUE. Otherwise if one of your device is off, the driver is uninstalled and etc.

Incoming search terms:

  • windows 7 sysprep
  • win 7 sysprep
  • windows 7 sysprep answer file
  • brian lee jackson sysprep
  • sysprep windows 7 download
  • sysprep unattend xml
  • unattend xml windows 7
  • windows 7 unattend xml
  • download sysprep windows 7
  • sysprep windows 7 unattend xml

 
  • Pingback: Taskbar Icons with Windows 7 Sysprep V2 - The IT Bros

  • Pingback: Sysprep a Windows 7 Machine – Complete Tutorial - The IT Bros

  • dave

    Hi there,

    I just wanted to drop by again to express my gratitude.
    you have helped me with a few steps in creating the ultimate lazy admin w7 image ;) .

    kind regards

    • http://theitbros.com/ Brian Jackson

      Thanks Dave :) Glad to help. Now on to Windows 8 imaging… some new fun stuff.

      • tabakong

        Hi Brian, Do you know how to skip the product key input in windows 7 installation? I created Windows 7 SP1 AIO x86/x64 and I want my Windows 7 AIO not to show the product key input during the installation. TIA

  • http://twitter.com/bkz81 bkz81

    Is there a way to include office 2010 x64 in the sysprep? We have a lab here with 18 laptops but they are not connected to the internet. Thanks for the guide it was a life saver for me.

    • http://theitbros.com/ Brian Jackson

      Yes, there is no reason when you build your image that you can’t have Office 2010 installed. I will see if I can hunt down the script we ran to activate Office. We had a script that would activate office separately after the sysprep.

      • http://www.facebook.com/david.l.pace David Pace

        Did you happen to find this script? I am banging my head trying to figure out how to do that.

        • http://theitbros.com/ Brian Jackson

          Tracked down from friend still at my previous employer… here it is. This is for Office 2010. Simply create a .bat file with the following:

          slmgr -ipk ***KEY***
          slmgr -ato
          cscript “C:Program FilesMicrosoft OfficeOffice14OSPP.VBS” /inpkey:***KEY***
          cscript “C:Program Files (x86)Microsoft OfficeOffice14OSPP.VBS” /inpkey:***KEY***

          Hope that helps!

          • http://www.facebook.com/david.l.pace David Pace

            Thank you. Is there a pass in the unattend file where this batch file can be run? Specialized pass maybe?

          • http://theitbros.com/ Brian Jackson

            You should be able to run this in Step 12.

          • http://www.facebook.com/david.l.pace David Pace

            I think that the script above is for 2 versions of Office 2010.

            64 bit Office 2010

            cscript “C:Program FilesMicrosoft OfficeOffice14OSPP.VBS” /inpkey:***KEY***

            32 bit Office 2010

            cscript “C:Program Files (x86)Microsoft OfficeOffice14OSPP.VBS” /inpkey:***KEY***

          • http://theitbros.com/ Brian Jackson

            Oops, you are correct. I just grabbed from my batch script and pasted… Thank you for the correction. We might have been running both depending on which platform we had, and one would simply fail if the path didn’t exist.

  • b579781

    After many hours of battling, I also found that a registry entry must be added for sysprep to look in the C:Drivers location. In HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/Current Version click on “DevicePath” and enter “C:Drivers” (remember the entries must be sperated by a ;) . More info here: http://technet.microsoft.com/en-us/library/cc753716.aspx

    • http://theitbros.com/ Brian Jackson

      Thank you for your comment. We have added your suggestion as tip #3 in the post. Glad you got it working!

  • http://www.facebook.com/paul.storic Paul Storic

    Will this work with a Dell OEM key?

    • http://theitbros.com/ Brian Jackson

      If you have a Dell OEM key for one use, I would use the following instructions above as a tutorial for building a sysprepped image, and then simply skip the license key part in sysprep and manually activate windows after the fact.

  • http://twitter.com/eagle_mitchell Mitchell Milligan

    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”

    Two Quick notes on this:
    1. When you run the command prompt it needs to be an administrative command prompt, to do this press start, and type into the search cmd then right click on cmd and select run as administrator. Next navigate to the sysprep folder by typing: cd sysprep and pressing enter.
    2. when you run the sysprep command, a more proper syntax would be this order: sysprep /generalize /oobe /unattend:unattend.xml /shutdown

    Other than that, exceptional tutorial!

    • http://theitbros.com/ Brian Jackson

      Thank you for your comment. Yes, little things I always forget, like telling people to run CMD as administrator. I have added your changes above to the post. Thanks again.

  • Bob

    Once you have created the answer file you say to take to the Windows 7 installation on the target PC. With the target PC using the microsoft media no sysprep message appears. Its a clean installation and has no knowledge of the work done within WAIK. There must be something missing …. From step 8 to step 9…. how dose the target PC in step 9 possess the configuration worked up on the servers WAIK?

    • Michael Hughes

      Hi Bob. So the .xml file was created and saved somewhere. Now begin a standard Windows 7 installation on a target machine and hit ctrl+shift+f3 as described in step #9 to enter ‘audit’ mode and continue with steps 10-13. In step #13 you will copy this .xml file to the target machine.
      If you are unable to get to the screen where Windows prompts you for a username, then maybe you’re using an OEM recovery DVD rather than a genuine Windows installation DVD? The latter is required to install the OS from scratch.
      -HTH!

  • Sam

    To keep the drivers installed to the computer there has to be a option under “generalize” (Microsoft-Windows-PnpSysprep_neutral -> PersistAllDeviceInstalls=TRUE and DoNotCleanUpNonPresentDevices=TRUE. Otherwise if one of your device is off, the driver is uninstalled and etc.

    • http://theitbros.com/ Brian Jackson

      Thank you for your comment. I have added this as an additional tip at the bottom of the post.

  • Craig Wellman

    Could you please expand on how to enable the image to work on multiple hardware types? I use Intel and AMD machines but am not sure how to manage the drivers using one image. Thanks in advance.

  • erich

    Thank you very much for this. It has really helped us out.

    However, we are seeing a really odd problem that seems to be tied to Audit mode. At least we don’t see it on a naked install of Win7(x64), but after booting into Audit mode (Step 9), it is repeatable and worse yet, doesn’t go away after sysprepping (step 13). It sticks with any machines the image is dropped on. We are creating the master setup on a VM.

    The Problem: Once any CD/DVD is inserted and then ejected (after Windows “sees” it), both PowerShell and any MMC (incl. Computer Management) will not start until any CD/DVD (not even the same one) is inserted. The message window cannot be canceled, ignored or force quit. Prior to the disc insert, both PoSh and MMCs work just fine, but until a reboot neither works without a disc in the drive (virtual or otherwise). We are seeing this on both the Professional and Enterprise flavors of Win7.

    Any suggestions on why or where to look?

  • Pingback: [WDS] Windows 7 equivalent to Sysprep.inf?

  • Pingback: The case of the missing INSTALL.WIM file...

  • Rafał D.

    Hi, I have few questions:

    -how to preserve drive letters in image? For example, I want OS to be on C: drive, some data on D: and I want assing letter Z: for DVD drive

    -can I update Windows and apply all fixes from Windows Update before making sysprep. When, in which step should I make this operation?

    -I have software which creates local user account. How to preserve/recreate this user on clonned system?

    Thanks in advance

  • Pingback: Complete PC backup to deploy Windows 7?

  • Juho

    Really good article! Thanks a bunch.

    • http://theitbros.com/ Brian Jackson

      Glad we could help!

  • Pingback: Новости » Blog Archive » Добавляем WDS универсальности

  • Pingback: Добавляем WDS универсальности » Просто простой блог

  • http://www.facebook.com/michael.jude.129 Michael Jude

    Haven’t visited the page in a while and there are lots of good tips added.
    Wanted to ask a question because I have tried to capture out of Audit mode and not having much luck. I dotn do it intentonally, but smetimes the PC doesnt auto login to audit mode and comes up with the normal admin login. I dont wont to waste all the time re-updatig and changing my configs. Is there a way to go back into audit mode after it goes back to user logins….and still start normally next time. After this it always stops at “Windows could not finish configuring the system. To attempt to resume configuration, restart the computer. ” and loops. Safe mode and the repair cd’s don’t help after this point :(

    • http://theitbros.com/ Brian Jackson

      So you boot into audit mode at Step 9…. do some updates, reboot, and it doesn’t go back into audit mode? Is that the problem?

  • Cláudio Roberto Gonçalves

    Hi.
    “Funtastic”.
    Can I translate this article and post in my comunity site?

    • http://theitbros.com/ Brian Jackson

      Sure, go for it! Just make sure to post a link-back to us please at the bottom :) We put a lot of work into our articles. Thank you. If you send us a message when you have it up, we will add a link to your site as well :)

  • ZMan

    I follow your guide but the sysprep is not using the script to join it to the domain. I know it works because I run it and it works from the system. Any ideas?

    • http://theitbros.com/ Brian Jackson

      Using the script to join to domain? Our tutorial assumes you will be joining the domain afterwards. The reason we didn’t bother scripting the domain part was because we had so many different naming conventions for computers, that it was simply easier to do it manually after the deployment of the sysprepped image.

  • Markas

    I have used many features from this post to create my own version of unattend.xml, and my win7 sysprep been working fine. Until recently my windows activation failed during unpack. When the computer got to the control alt del screen (joined to domain) and login, the first message I see is windows is not geniue and ask to activate. If I cancel out the activation process cscript start to run and active windows for me. From the pass windows activated during unpack stage. The last modify to the script is only added below component in generalize section.

    true

    I have been using the same script for monthes. Even I roll back and use older version of unattend.xml, it does the same. Has MS changed the security handling in the windows activation? Any one got any ideas?
    PS. I am using MAK key and the activation is 100% working from cscript end.

    • http://theitbros.com/ Brian Jackson

      Did you ever figure this out?

  • hik3

    Dear Brian, thanks for this awesome tutorial! However I have a question for you. We recently bought a bunch of HP Elite 8300 SFF computers, which are running with two disks (one HDD SATA of 500GB and another SSD of 20 GB) in RAID1 with SSD-cache. I installed the Intel RST drivers to support the RAID, but after the sysprep /generalize /oobe /shutdown /unattend:sysprep.xml the system turns off, and when I turn it on again I got the error message “Windows could not finish configuring the system. To attempt resume
    configuration, restart the computer”, but it is stuck in a rebooting while. Do you have an idea ?

    • Mattastic

      I’ve also seen this as well. I had thought there had been something I’d done wrong, but after a week of fighting I finally rolled back to an earlier snapshot(I use VMware for building the deployment). This fixed it perfectly. I didn’t have to make any changes to my unattend.xml, just simply roll back…I think M$ breaks itself at some point.

  • Pingback: Creating mandatory profiles for Windows 7

  • SomeTech

    If you’re using a Key Management Server (KMS) to manage licenses you’ll have to change the ‘SkipRearm’ value to 0 before you sysprep the machine for the final time.

    An image that was sysprepped with SkipRearm=1 in it’s unattend.xml will have the same CMID for all the machines cloned from it, regardless of whether you used the /generalize switch. /generalize will only reset the machine SID if the SkipRearm flag is set to 1.
    This causes all KMS activation requests to appear as though they’ve come from the same machine and your KMS server won’t be able to tell them apart or hand out licenses, especially if it hasn’t passed it’s activation threshold yet.

    If you’re using a KMS server you don’t need to use these commands either as your machines will automatically try to contact the KMS server upon boot:

    FirstLogonCommands
    1. CommandLine: cscript /b c:windowssystem32slmgr.vbs /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX (windows 7 license key)
    Order 1
    RequiresUserInput: false
    CommandLine: cscript /b c:windowssystem32slmgr.vbs /ato
    Order 2
    RequiresUserInput: false
    SynchronousCommand[Order="1"]
    SynchronousCommand[Order="2"]

    I recommend capturing a system image before (and after) running sysprep so you always have a reference point to return to for adding/removing features, programs or making other tweaks to your image and not have to worry about sysprepping the same image multiple times.

    For more info see: http://technet.microsoft.com/en-us/library/dd744512%28WS.10%29.aspx#ResettingWindowsActivation