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

Note – I highly recommend creating a boot or rescue disk before starting any windows 7 technical projects. There are many tools in the market and I use Spotmau BootSuite rescue software and boot disk utility because of it’s versatile features and top notch performance.

Windows 7 Sysprep

Last Updated on 06.08.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
  • stan oobe
  • win 7 sysprep
  • windows 7 sysprep answer file
  • it bros sysprep v2
  • 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.

          • Matt Voss

            Would this work for Office 2013, and also.. how would you delete this .BAT file so that the keys aren’t left on the computer?

  • 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!

    • Nick Khalansky

      Please, show a sample.

      And how about subfolders c:driverslan;c:driversdisplay;…..?

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

    • Firekeeper

      I have 50 models of laptops ans desktops – This method works flawlessly if is done proper so:

      Step 1 : On you image at setupcomplete or first logon commands or simply first start-up you have to put one little bat or cmd that looks like this:

      @echo off

      ::~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

      if %PROCESSOR_ARCHITECTURE% == x86 (

      goto :x86

      ) else (

      goto :x64

      )

      :x64

      forfiles /P %systemdrive%Driversx64 /S /M *.inf /C “cmd /c pnputil -i -a @Path”

      goto Next

      :x86

      forfiles /P %systemdrive%Driversx86 /S /M *.inf /C “cmd /c pnputil -i -a @Path”

      goto Next

      ::~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

      :Next

      shutdown /r /t xx /c “bla bla whatever”

      This means that this cmd will see what win you have x64 or x86 and if it is x64 will install whatever inf files it founds in C:ITDriversx64 and recursive scan all subfolders from that level down…

      If is not x64 and is x86 will install all inf files from C:ITDriversx86 and all sub direcroies it finds from that level down.

      Basically it uses a combination of frofiles and Microsoft pnputil built in windows 7 and above. Checkout pnputil /? for more.

      -i -a will add the drivers to windows store and install them same time.

      After this at :Next the rest of your script will go as you plan it and the reboot from the end is mandatory. Is posible that you need to set autologon count value to 2 or more.

      Because I have many different hardware will use after restart winsat dwm instead of prepop commad for aero…

      Sure you need to have a folder that contains Driversx64 x86 structure declared in cmd but that’s the easy part. On youC drive make a folder called 1 and in it onother Drivers that contains x64 folder and x84 folder. Now download from HP or Dell for specific model drivers manageability pack or dellA.xx cab these have all the drivers at one big pack, extract them and simply throw x86 drivers to your x86 and x64 to your x64 doesn’t matter the names as pnputil will scan all the substructure dir.

      Now test the drivers to be all signed as pnputil and win7 will not accept unknown publisher drivers and you want to avoid continue anyway pop-up box.

      These junk drivers such as jmicron or atheros will have to deploy with a separate script that uses silent switches setup.exe /s or /S /v/qn depends…

      So put this script if is needed for a specific model also in your drivers 1driversSoft and remember to call it after restart.

      Now capture 1 folder imagex /capture /compress maximum c:1 d:hp8470.wim for example. Deploy this wim immediately after your wim OS image and that’s it.

      The hard part is to predetermine what model of computer you have before you apply wim OS image. For this You have to put in place in PE some vbs that do a wmi query to determine the right model.

      All brands have a unique code for a specific type of machine that looks like:

      For HP is something like 309AH HP Elitebook 8470p

      For Dell is Dell Latitude E5410.

      So make an challenge- response mechanism with all your models and associate the response of wmi query to a wim pack for the specific model or put the vbs to phrase an xml file.
      “309AH”–>”HP8470.WIM”

  • 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?

      • Apur

        IS ther anything changed with your prxoy/internet settings ( server )? This can cause the activation to fail.

      • Markas

        I think I found the issue. I ghosted a windows audit to save time install it during testing. I used he same ghost image to build the final version. So its might detect its reached the activation period (3 days? or 30 days can’t remember). I started from scratch and its all fine. WIndows activated prior/on first logon.

  • 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

  • Pingback: Deploying Windows 7 | stvnbsh

  • Virtual Cheesecake

    Hi Brian & All Commentors below!

    A lot of good input with this thread, and great that it is still active today – as some environments are still making the jump to Windows 7 (dont judge!)

    I wanted to query the Activation Process (Synchronus login steps) and also the Post sysprep SetupComplete.cmd

    I’m finding that on first login, i get the command window where the computer is obviously running cscript with the syntax from Step6 of Windows Activation, however when i get into Windows – it is not activated?

    Additionally – the SetupComplete.cmd does not run?

    Originally i noticed it didnt have permissions to run the delete process – so i go around this by disabling User Account Control. However although i can run it manually now, it still doesnt process it when logging in?

    I’ve also added Office 2010 activation to the FirstLogonCommands as step 3, but that doesnt appear to work either!

    Would appreciate anyones input :-)

    • Markas

      First Loong batch file works for me. I put everthing in a batch file when I ready to run sysprep on audit mode.

      md c:windowsSetupScripts
      move /y SetupComplete.cmd c:windowssetupScriptsSetupComplete.cmd

      Make sure SetupComplete is on SetupScripts folder. You can copy the file manually if you want.

      Also for office activation I have incuded it SetupComplete.cmd and I have found you have to check the status prior activate the office. See below command line

      cscript “C:Program Files (x86)Microsoft OfficeOffice14OSPP.VBS” /dstatus
      cscript “C:Program Files (x86)Microsoft OfficeOffice14OSPP.VBS” /act
      cscript “C:Program Files (x86)Microsoft OfficeOffice14OSPP.VBS” /dstatus

      For this method to work, your office key must be embeded in the office installation. I use the customised MSP method and build my customised office 2010 installation. See this link:

      http://technet.microsoft.com/en-us/library/ee656736(v=office.14).aspx

  • victor hugo velazquez martinez

    Hello, thanks for the how-to, and i will like to translate it to spanish, of course if there is no problem with you.

    Cheers

    • http://theitbros.com/ Brian Jackson

      We would love to have a translation in Spanish. Please include link back to our article. We will post link to your translation as well.
      Thanks!

  • Pingback: Creating a syspreped Windows 7 Image for KACE | Fawlty.us

  • Harry Tapp

    Hi, a glitch with the unattended.xml. After I control+shift+F3 to enter audit mode as Administrator after primary installation. I do my customizations and updates (choose public to avoid wmp/sysprep error) I insert the usb with unattended.xml created from your instructions right as I sysprep /generalize /oobe (using gui). When the system restarts it enters the phases of installing devices then gets error panel that says “unable to process there is an error in unattended.xml… specialize pass amd64_Microsoft-Windows-Shell-Setup_6.1.7600.16385_neutral. I think it is the copy profile item.
    Let me know what you think
    Harry

    • Guest

      I’m getting the same error. Did you find any solution?

      Thanks!

      • Harry Tapp

        This was some time ago. I could not get the copy profile to work so I abandoned the unattended.xml After entering audit mode/Administrator I went to computer properties – Advanced system settings – User Profiles/settings amd selected *administrator the “copy to” button was greyed out so I found a program called “EF Enabler” which then allowed me to copy the profile to an alternate location. Then I copied that profile to C:UsersDefault (Not Default User) – these are hidden, then sysprepgeneralizeOOBE after shut down copied the partition to an image using Hirens boot with terabyte for windows on to an external usb hard drive. creating the Hirens boot disk [usb/cd/dvd] is another project :-) This way when you apply the image to a target machine and boot it for the first time it goes to device install and OOBE asking for a user name. This user and all users thereafter will get the default settings and programs that the Administrator had in audit mode after customizations. One thing to remember is during initial setup of the reference machine when you choose an install partition and format it windows will create a “System Reserved” 100Mb partition after it does this delete the install partition you just formatted and then extend the “System Reserved” partition to take up the unallocated space just created by the deletion. This will force windows to put the system and boot files on the same partition (make sure you have no other hard drives attached to the motherboard) The only negative side effect is bitlocker can not be used but doing this will save headaches later as you will have only one image to copy and apply. I found that when using [G]Imagex to do the imaging work when I applied to the target machine it would not want to boot and had to go through using Win 7 repair boot media nightmare. Terabyte backup achieves consistent results. While in audit mode you can change the volume label to “Win 7″ and the hirens disk to open partition wizard and change the “Disk Type ID” on Win 7 (C:) to “0×07 [NTFS] (may have to do this when booting to capture the image)

  • Albert

    Hi Brian,

    I have followed your instructions and was able to sysprep. Everything is working fine except for the the multilingual (which I have configured to allow the users to swicth language bwteen multiple languages on a single running computer), however when I run sysprep, the multilingual has disappeared. Your help is very much appreciated.

    Thank you in advanced.

  • curtis

    Hi Brian,

    Will this setup work for me? My situation: I was not able to run Sysprep on my old computer because the motherboard and CPU are fried. Obviously, the old hard disk won’t boot in the new computer. I need some way of removing the drivers from the old hard drive. The new computer does has a new hard drive. I have Windows 7 ultimate install CD.

    Thanks!

    • Curtis

      You should be able to boot the old HD in the new PC. The old drivers wouldn’t run if the applicable device is not present. The best solution regardless, is to do a fresh install on the new HD, connect the old HD and copy the files you need to the new drive.

  • Daniel Saez

    Thanks for this.

    After i syspreped i can capture a wim image of the windows partition, but how do i make that bootable so i can install into another PC?

  • Bill Gilligan

    Do you know if it’s possible to move the Specialize pass in the unattend.xml to after the OOBE pass? (Well, obviously you CAN, but will it work is the question haha) This way you can name the computer, but then also run the unattended join and have it auto join the network.
    Great tutorial. I’m sure I’m not the only one who feels that MS has made this a needlessly complicated mess as opposed to WinXP’s version of sysprep.

  • oweb

    Hello Brian,
    thank you for this article.
    Is it possible to prepare a Master apps?
    I would like to install 10 or 12 software “automaticly” (without installing Windows).
    Is it possible with thie method?
    (sorry for this question, but I’m not expert)

  • Jose Ponce

    Good afternoon, thanks for the awesome tutorial, I dont know if this has been mentioned, but I want to share some info. When I did the xml for 64 bit everything went great, but when I did it for 32 bit I run into the proble were I was not asked for the computer name. What I had to do is add any carracter to “Computer Name: Leave blank (we will deal with this at the end)” so it would create an entry on the xml. Once the xml was created I was able to find the computer name and delete it, once I did this I was able to be asked for the computer name.

  • Jose Ponce

    Has anyone found were to add the company wireless ssid and password?

    • Markas

      Its going to be complicated since each machine’s wireless card has unique GUID value, and even if you get the GUID after OOBE stage, I am not sure a simple copy paste profile will work on the new machine as I haven’t test it myself. The wireless profile are stored under c:ProgramDataMicrosoftWlansvcProfilesInterfaces[Interface Guid].
      The profile name and key are encrypted and stored in above path.
      If you find a way to get the wireless card GUID then you start try copy the profile across and test it.

  • Yannick van Rooyen

    If somebody is deploying these images using MDT (No SCCM), i’ve written some articles about configuring MDT so you can have an unattended installation where the computer takes it’s name from AD and you don’t have to go to the computer to press the F12 button. It’s in Dutch, but if 10-ish people ask, i’ll translate the articles to English. http://helionit.nl/easyblog/zerotouch-deployments-met-mdt-zonder-sccm-en-met-res-automation-managerZeroTouch%20deployments%20met%20MDT%20zonder%20SCCM.html

    • http://theitbros.com/ Brian Jackson

      Yannick. Would you be willing to translate your article and share it on theitbros.com blog for our readers?

  • Jiri

    Hei Brian, thanks for this pig pick, this is really the best guide for this theme. I am deployng 48 hour now but still confused. I have got across many bariers, but the last one is the hardest one. My sysprep proces ends with:

    2013-09-11 08:27:25, Error [Shell Unattend] TakeOwnerAndDeleteKey failed (0×80070002)
    2013-09-11 08:33:48, Error [msoobe.exe] Failed to install product key [hr=0xC004F050]
    2013-09-11 07:52:25, Info [Shell Unattend] CopyProfile succeeded

    The profile was not copied, never ever … :-(
    I did not try to install any product key…
    Or there is problem with some security permisions to profile?

    I don’t understand the difference between MAK and KMS, I have both keys for our school.
    MAK is usually working for manual activation. Windows has been activated in audit mode using MAK key.

    I have tried from complex to simplest xml configuration, but nothing works:

    true

    I have get across IE10 bug and I must uninstall antivirus, because any software with special security is not compatible with sysprep, now I know :-)

  • Phong

    Hi Brian,

    GREAT ARTICLE!! IF I wanted to be able to take the image and put it onto a fresh new PC and gets prompted for a new computer name and to be able to join the Domain once the computer name is provided, how can I go about doing that with the sysprep? Please advise whenever you get a chance.

    Best Regards,
    Phong

  • Jadzla

    Excellent article. Does sysprep also need to be used when using programs such as Parted Magic to clone and deploy several machines? or can I just install a machine from the base image created, along with all programs needed for a workstation then rename it on the domain (or remove from domain and re add) after the restore from image?

    • sane37

      The problem with doing it without sysprep is that the CMIDs and SIDs of the imaged machines will be the same which can cause issues on the network.

  • Jai Hawkins

    Thank you for this article, it helped me a lot when creating a Windows 7 Enterprise image for my organisation. Although, I have deployed a few machines and have run into a problem. A user cannot print colour jobs, she is the only user using a Windows 7 machine to print to this printer.

    To troubleshoot this, I added the print queue to a machine I prepared with a fresh installation from disc and do not have the same problem. Coincidence? I have tried with 2 reimaged machines and 2 normal installation machines. The image has some kind of issue. Everything ran smoothly upon answer file creation and capture. So cannot understand what is causing this.

    Has anybody else had a similar issue? If so, would you be so kind as to let us know if we can do anything to rectify it?

  • Del

    Hi, The unattend.xml file does not seem to delete after rebooting, could you advise why that may be the case?

    • http://theitbros.com/ Brian Jackson

      Sometime Windows 7 could act funky. Try rebooting again.

  • Cláudio Roberto Gonçalves

    One of the things I do for Windows Clients and Servers is disable the AutoPlay features:
    Win+R type gpedit.msc

    Navigate to ‘Computer Configuration Administrative Templates Windows Components Autoplay Policies Turn off Autoplay’.
    And enable it.

  • morrowg

    Hi Brian,
    I’ve been using your well documented steps for 3-4 years now.
    I remodelled my sysprep environment using your steps as the foundation.
    Created my last two images Win7x86 and Win7x64 in VMware and I’ve successfully deployed these images to 3 generations of PCs both desktop and notebook over the last three years.
    I updated my Win7x64 image with new driver cabs, windows updates, flash, java and sep etc.
    Sysprepped and attempted to deploy.
    Unfortunately during the device installation phase of minisetup i hit a BSOD 0x0000007E at 86%.
    I’m unfamiliar with how to troubleshoot at this point. It does create a minidump but have no way to get it. Suppose I could mount this as a second drive on another system.
    Have you encountered anything like this?
    Would appreciate any tips.
    thx. in advance.

  • Darren Skinner

    Once the machine has been sysprep’d and imaged (imagex) can this be deployed to any machine or will I have to create an image for each model?

    • Steve Davis

      Yes you can as long as you have the “Windows-PnpSysprep_neutral -> PersistAllDeviceInstalls=TRUE” set as FALSE(default). You also want to be sure to put the drivers on your image somewhere that the OS will find them or set the drivers folder to be searched as seen in Tip 3.

  • Caleb

    Maybe I missed something somewhere so excuse my ignorance, but in step 11, how does it know to look at my unattend.xml file to see my copyprofile parameter when that file isn’t on this computer because it’s a fresh install? Am I supposed to put it in the sysprep folder?

    • Harry Tapp

      The system will check the root of every file system identified/connected and look for the specific file name “unattend.xml” if more than one exist it will use the first one found.

    • Steve Davis

      See Step 13: Once you have everything configured correctly, Copy or move your unattend.xml file to : C:windowssystem32sysprep. Then it reads the copyprofile = true

  • Skellz

    I tried making an answer file to this guide but got an error saying it basically encountered an error trying to read the unattend xml file. Can you post your actual example answer file so I can troubleshoot?

  • Firekeeper

    One big issue:
    Why do I get randomly under users Administrator.Computername and Administrator forder empty.
    I do have copy profile in unattend.xml and it is copied corect but not completly removed the old one each time.
    I entered in audit mode to customise profile. and I saw the local Administrator account was disabled as supposed to be. Should I enable local Admin account to get rid of this annoying new Administrator.Computername, give full rights on folder berfore capture what could be the reason for this unproperer behave?
    I have put in place in audit mode 1 script per machine startup via gpedit.msc (some local vbs) and 1 for users – template -clean start menu for new users – that’s all the rest is done after autologon via vbs scripting.
    Please help

  • aalia lyon

    It’s a Fantatsic blog . this blog helps you
    for any kind of windows7 error . we provide best services for your any type of
    windows 7 error . go through this site .

    error 1068
    windows7

    Thank you

    Aalia lyon

  • Porkupine Spine

    Hi Brian, love your work – very good detail and walkthrough… question for you though – after all this is said and done, is it possible to REVERSE engineer this out and solely “hack” the volume iso out from WIM with its key without disturbing the other apps etc ?

  • Sholay

    Hi Brian, It’s fantatsic work and work great.
    I have an issue, any machine build with the captured image, I am not able to Boot in safe mode with Networking. it goes to screen saying Loading Windows files and got stuck on the line saying
    Loaded: windowssystem32driversCLASSPNP.SYS
    Any idea?

    • Steve Davis

      Why would you want to boot into safe mode? If you follow the steps and image properly you should be booting into Windows without any issues.

  • frame45

    How in the heck do I get it to NOT prompt me for a computername I want this automatically so that this is an actual UNATTENDED install. Not a stop and enter the PC name install.

    • Steve Davis

      At step 8 did you put in the computer name in the namehere field? For doing mass deployments you may need to do it a different way with whatever imaging tool you’re using.

      • Joe L

        Hello Brian, hope u can help me out here. I want to create a win 8.1 enterprise 64-bit answer file that will enable local administrator, also enable an additional local admin user, leave the current device drivers, disable windows firewall, keep windows. 8.1 product key (we use volume license) so that we dont have to enter manually everytime. Ask only for computer name after reimaging and dont have to ask for office 2013 poduct key as well. Sorry for the list but really need ur help! Jaluna75@hotmail.com

  • Keith Drake

    I have followed this document. How do I get a Win7 PC to activate if I have no internet access?

  • Shuaib Rawat

    Thanks for the excellent guide. I have put the product key in the unattend file as shown but it still prompts me to enter it when starting up the target machine. Why does it do that?

  • Alyshu

    Hi. I’ve got one question about point 15 : “you will be automatically logged into the administrator account, and the unattend.xml file is deleted.”

    When a client boot his machine, I want oobe welcome window display. I don’t want to be automatically logged into the administrator account… How can we do ?

  • Joe L

    Hello Brian, hope u can help me out here. I want to create a win 8.1 enterprise 64-bit answer file that will enable local administrator, also enable an additional local admin user, leave the current device drivers, disable windows firewall, keep windows. 8.1 product key (we use volume license) so that we dont have to enter manually everytime. Ask only for computer name after reimaging and dont have to ask for office 2013 poduct key as well. Sorry for the list but really need ur help! Jaluna75@hotmail.com