Sysprep a Windows 7 Machine – Start to Finish V2

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.1 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:

Windows 7 WAIK Version 1

Windows 7 WAIK Version 1

Step #3

Under the “Windows Image” header, right click and select new image.

Windows System Image Manager

Windows System Image Manager

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.

Selecting CLG File - WSIM

Selecting CLG File - WSIM

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.

Answer File - Unattend.xml

Answer File - Unattend.xml

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

      1. Order: 1
        path: net user administrator /active:yes
        WillReboot: Never
    1. RunSynchronousCommand[Order="1"]

  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
    1. 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
    1. SynchronousCommand[Order="1"]

      SynchronousCommand[Order="2"]

  • OOBE
    1. HideEULAPage: true
      NetworkLocation: Home
      ProtectYourPC: 1
  • UserAccounts
          1. Password: Administrator Password
        1. Action: AddListItem
          Description: Local Administrator
          DisplayName: Administrator
          Group: Administrators
          Name: Administrator

      1. LocalAccount[Name="Administrator"]

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

    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:windowssystem32sysprep. 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.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!

    • Harry

      you can use mysysprep to promp for prod key http://www.tsaysoft.com/mysysprep2/

    • xzn2p3

      Anyone know how to disable certain network settings in the answer file. Like to have IPv6, File and Printer Sharing and NetBIOS turned off when the system comes up after sysprep. Sysprep turns them all on again. Is it possible to run a script like the one that activates Windows like in Step 7 above?

    • Mark

      Thanks for this very helpfull guide!
      It was really annoying to get this thing working, until I found this guide!

      Many thanks!

    • Pingback: Taskbar Icons with Windows 7 Sysprep - Windows Walkthroughs

    • http://www.verilogue.com Dan Scrima

      I’ve done all the steps up until its time to install software. I join to the domain, install software, do some configurations. When I reboot, however, I keep getting an error “Windows could not complete your installation.” and then it reboots and is no longer in audit mode! I tried to get it back into audit mode through the sysprep cmd but it gave me that same error again. I installed software like mozypro, office, firefox, simple programs like that.

      Any ideas on why it keeps doing this??

    • Bill Swallow

      Brian – Thanks for the info. Been cloning machines since Win95 (2000, XP, Server 2K3, I even have 2K8 cloning nicely with WDS. After 2K8, I figured Win7Ent X64 would be similar. I built my reference machine, and ran ‘Sysprep /oobe /generalize /shutdown’ with no .xml file, as I do on Win2K8. When I rebooted my reference machine, I got the dreaded “Windows could not finish configuring the system” error. Looking for an answer, I found this site.

      I followed your directions to build an ‘unattend.xml’, but I am greatly puzzled by one thing. When I add ‘amd64_Microsoft-Windows-Deployment_6.1.7600.16385_neutral’ to pass 4 – specialize, it comes up with it’s icons sorta – translucent – compared to the other entries. And I purely *cannot* find the ‘order’, ‘path’, ‘willreboot’, etc. parameters under it that you reference. Those fields are just nowhere to be found. Anyone have any thoughts?

      I installed Windows System Image Manager from ‘KB3AIK_EN.iso’. It’s showing a version number of 6.1.7600.16385. I installed it, and am running it, on my Windows Deployment Services Server, which runs Windows Server 2008 R2 x64. I started my unattend.xml file from the “install_Windows 7 ENTERPRISE.clg” file from my Windows 7 Enterprise x64 install DVD. Just can’t figure out *why* that entry is acting strange.

      Thanks again.

    • Bill Swallow

      P.S. – addendum to my previous post. In the ‘components’ pane of Windows System Image Manager, in the lower left, the source for ‘amd64_Microsoft-Windows-Deployment…’ shows the following subheads – AuditComputerName, ExtendOSPartition, Generalize, Reseal, RunAsynchronous, and RunSynchronous.

      When I add it to pass 4 – specialize, all that comes through are ExtendOSPartition, RunAsynchronous, and RunSynchronous. The other subheads are gone, and the ones that do get added show ‘icon boxes’ in the Answer File tree that are much lighter in color than the other entries, the ones that are working as described, like ‘amd64_Microsoft-Windows-Security-SPP_neutral’.

      Anyone else ever see this phenomenon?

      Thanks.

    • Pingback: Network not working after imaging - Altirigos

    • Satish

      Hi,
      I have done everything but some errors are executed can you help me out from this..

      Setting SkipAutoActivation is deprecated in the Windows image Components/specialize/amd64_Microsoft-Windows-Security-Licensing-SLC-UX_neutral/SkipAutoActivation
      The component does not have any updated settings. It will not be saved to the answer file. Components/oobeSystem/amd64_Microsoft-Windows-Shell-Setup_neutral
      Setting StartPanelOff is deprecated in the Windows image Components/oobeSystem/x86_Microsoft-Windows-Shell-Setup_neutral/StartPanelOff

      Satish

    • salim

      Hello,

      Thanks for your advices. Really Great.
      I read some months ago, a way to force prompting for domain and credential box.
      Does anyone have any idea to implement it please ?

      Thanks Long live to this site, it helped me so much.
      Salim

    • Derek

      Hi,

      Very informative guide thanks!
      @salim: A nice tool you can look at using is mysysprep2 from http://tsaysoft.com/mysysprep2/

      This should allow you get to prompt’s during setup for computer name, domain name and credentials amongst other things.

    • santosh dharamsale

      i captured the image and when i am installing the image i am getting this error ” your computer’s name is managed by your organization’s system administrator” in some of the computers but same i tried in different machines its working fine, i am able to keying the PC name.

      please can you help me in this regard.

    • Devin

      I have a quick question. I have a sysprep file for Win7 32-bit that was created by the tech before me at my company. The file works perfectly. We are now looking at going to Win7 64-bit on some machines. I’ve tried creating a sysprep file for Win 7 64-bit, but I keep getting errors. I was wondering if I could copy the existing 32-bit file and replace the x86_XXX… entries with amd64_XXX. Would that work or am I not going to be able to do that?

    • Pingback: DS 6.9 SP3 Noob - Altirigos

    • David K

      For the unattended.xml file is there are way to set the UAC level for all users?

    • David K

      Also for the unattended.xml which component would I use to add internet explorer favorites? Is it “Microsoft-Windows-IE-Internet Explorer? Would I use FavoriteBarItems or FavoritesList? Finally If I use the above component which section would I place it in the unattended.xml file? Would it be in 3 generalize or perhaps 3 specialize or 7 oobeSystem?

      I would appreciate suggestions.

    • Mac

      I see that you boot to WinPE environment. I am really new to Windows 7. Will your information work with Symantec Ghost 11? If so, what would be the differences? We have not yet moved to using Windows for imaging. Can you suggest anything that might help me?

    • Mike

      Got an error message: ‘Windows could not parse or process unattend answer file C:\Windows\Panther\unattend.xml for pass [oobeSystem].” blah blah blah. Then it reboots and says “Windows could not complete the installation. To install Windows on this computer, restart the installation.”

      What was interesting is that’s not the name of my unattend file. I specified the name of the unattend file on the command line as:
      sysprep /generalize /oobe /shutdown /unattend:7_enterprise_x86_sysprep.xml
      I also added the script in %WINDIR%\Setup\Scripts to delete this file. But why would Windows attempt to parse “unattend.xml” rather than the file I pointed it toward?…Turns out that the file under sysprep\whateveryoucallit.xml is renamed to unattend.xml when it is copied to the C:\Windows\Panther\ folder.

      A quick Google pointed me to http://support.microsoft.com/kb/947303
      “This problem occurs because you have set a value for the ShowMediaCenter option in the Unattend.xml file.” (Thanks for the ridiculous error messages, MS.)

      The only thing I could think of was that I had attempted to hide Windows Live:
      false
      So I hand-edited both the XML file under Sysprep and the one under Panther and removed two instances of the line above, but that still did not resolve it.

      What finally resolved it for me was removing a reference to the Administrator account, which I had actually disabled. So I hand-edited my unattend.xml and removed this entire section:

      net user administrator /active:yes
      1

      I aslo found that I had left this section in by accident, so I removed it too:

      YOURPASSWORD
      false

      Now it’s working. Thanks for the great guide!

    • Mike

      Ha! It stripped out all my xml code.

      The first component I mentioned removing was:
      component name=”Microsoft-Windows-Deployment” processorArchitecture=”x86″ publicKeyToken…
      RunSynchronous
      RunSynchronousCommand wcm:action=”add”
      Path net user administrator /active:yes
      Order1

      The Windows Live code to remove contained these keywords:
      ShowWindowsLive=false

      Then under User accounts I removed:
      AdministratorPassword
      Value YOURPASSWORD
      PlainText false

    • Long

      Hi All,

      I have caapture this….

      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.

      Then I have few questions here to ask…

      1) I am using the Sysprep within the Altiris to create/capture then deploy the imgages through the Altiris using an unattend.xml file. How do I using the Altiris to inject additional drivers for 3rd party brands, HP, LE, Dell, etc?

      Thanks for your help
      Long Ng

      2)

    • Pingback: FOG .29 My Windows 7 Guide (32/64 Bit) DocV1 | blog.ibuddy.info

    • Pingback: Win 7 Computername = Serial Number? - Altirigos

    • William

      I work for Managed Service Provider and I’m creating an unattended.xml file for 800 machines and I’m deploying Win 7 32bit. and I have almost every figured out for the most part. However I was wanting to know, where do I place the product key information, as to where I can run sysprep and have it prompt me for the product for User Input, instead of automatting the production input?

    • William

      Also What would be the string to have it prompt for the product key as well or Can I find it within Windows System Image Manager?

    • David

      Do you use KMS activation? With 800 machines it will be easier to stick to auto-generated serial and activate after installation is completed.

    • unattend is not deleted

      Hi, Thanks for this, great article – everything is all working well for us except that the unattend.xml file is not automatically deleted and remains in both locations ( c:\windows\panther\ or c:\windows\system32\sysprep\ ) following install – have I missed something ?

    • Alan

      I have some Apple iMac’s I need to set windows 7 sysprep to set default input locale to UK English Apple Keyboard. Any ideas?

    • http://Asapit.com.au Robert

      Plain and simple thank you. Your guide didn’t do much help me work it out but to understand all those pesky answers to unattended sheet And released hidden inspiration in me
      At this stage I have a 8gb wim file that can deploy windows 7 in 20 mins fully updated, and because of the audit mode, up-dateable as well.. Love it. Now I’ve gone and Scripted for network and USB deployment. Stupid labs never know what hit em now.. Bam all 30 machines rebuilt in half hour. Leaves xp deployment for dead!

    • Kaleb

      I think thats the skip activation part in the specialize tree, not a 100% tho

    • Kaleb

      generalize even

    • http://www.brianleejackson.com Brian Jackson

      An updated version of this is now available at our new website: http://theitbros.com/sysprep-a-windows-7-machine-%E2%80%93-start-to-finish

    • http://www.brianleejackson.com Brian Jackson

      Please post your question over at the new version of our blog here -> http://theitbros.com/sysprep-a-windows-7-machine-%E2%80%93-start-to-finish. Thank you

    • Tom King

      On your Step#8, I have it working but it always wants to add a local user. Since we will joining a domain and have no use for a local user we do not want to have to create one. I know I can just delete it but when I image 2500 computers when it goes thru sysprep it prompts to create a new user. I do not want to delete it on 2500 computers. Any help would greatly appreciated.

    • IamSam

      Has this changed with Windows 7 SP1?

    • Mitz

      Nice tutorial…..tested with windows 7 sp1 …. worked great.

      Thanks

    • cthao

      how do I perfrom windowsupdate in audit mode? It looks like it is disabled in Audit mode.

      I like to have an image with the latest Winodws/Office update, configured the profile and setting in audit mode but it looks like Windows update keeps giving me error in audit mode.

    • http://www.boutiquedusoda.com machine soda

      Nous venons de couldnt quittent votre site Web avant de vous laisser savoir que nous avons vraiment apprécié les informations utiles que vous offrez à vos visiteurs … sera bientôt de retour pour vérifier sur des slideshows nouveaux post-vous!

    • http://www.spotmaupowersuite.com Della Zavala

      you can also check out spotmaupowersuite.com. that’s a pretty awesome tool for stuff like this

    • Liz

      I haven’t made it through all the comments yet, but just wanted to say I already had my model image all set up so I skipped the audit section. I set up my default profile following the method described here by CascadeRob:

      http://social.technet.microsoft.com/Forums/en-US/w7itprogeneral/thread/0be9b1f0-a21f-4889-9568-6ec455689aa9/

      Just make sure to follow all the steps. In addition I discovered that the first registry key found in step 10 is the Wallpaper setting – in order to retain that setting I saved my wallpaper image in the Public Pictures Library while I was setting up the dummy profile to copy, then rather than deleting the Wallpaper key I change the username to %username% – worked perfectly. I’ve also experimented with loading the default ntuser.dat hive to make other minor default profile changes, like setting the IE home page to our website.

      Oh, and I don’t use the CopyProfile setting in the unattend.xml file.

    • Farzan Qureshi

      Hi,

      I followed all the steps. The language bar customizations does not appear on the target machine :(

    • Perry Driscoll

      Hi,

      I have tryed deleting the computer name line but still get no promt at install. Is there anyway around this?
      I have used Mysysprep which prompts for computer name but then does not add the machine to the network.

      Any help would be great it seems to be one or the other at the moment.

    • mike shull

      Having some issues.
      I am using WAIK version 3

      These are not available when I add amd64_Microsoft-Windows-Deployment_6.1.7600.16385_neutral to specialize

      Order: 1
      path: net user administrator /active:yes
      WillReboot: Never
      RunSynchronousCommand[Order="1"]

      RunSynchronous

      AND you can not add amd64_Microsoft-Windows-Shell-Setup_6.1.7600.16385_neutral
      to odbe system the selection is grayed out when you right click.

      Any thoughts?

    • Pingback: Sysprep a Windows 7 Machine - Start to Finish - Brian Lee Jackson