COE Exchange:

Archives

Windows 7 Deployment with Sysprep

    Share
Last Updated: January 13, 2010

Compared to [wikipop]Windows XP[/wikipop], deployment of [wikipop]Windows 7[/wikipop] has been much simplified. You know in XP, when it asks if it can connect to Windows Update to get drivers? Yeah, that actually does stuff in 7. Dealing with changing [wikipop search="Hardware abstraction layer"]HAL[/wikipop]‘s is also no longer a problem in 7.

7 handles deployment quite gracefully. We can literally just run Sysprep and deploy the image, and 7 will figure it out. Now, this isn’t the most effective way to Sysprep a machine, but if you need a quick image for something and you don’t mind sitting through the setup process, it works. Just like my article for XP, I want to say that I don’t know if the methods here are the “right” way to go about [wikipop search="Sysprep"]sysprep[/wikipop]-ing machines, but it works, and I think that’s what counts.

Sysprep is located in C:\Windows\System32\Sysprep by default (yes, it actually just comes with the OS). Just run it as Administrator, select Enter System Out-of-Box Experience(OOBE) and check Generalize. After the machine shuts down, take an image and deploy it.

Win7-Sysprep

You’ll then be taken through the normal setup routine (setting up an administrator, license key, etc). If the machine is connected to the Internet, 7 will try to find updates and proper drivers.

Deployment Using Windows System Image Manager (WSIM)

If you plan on deploying Windows 7, you definitely need to create an unattended installation answer file. Unlike XP, where the answer file was just a text file with some fields, 7′s is a more complicated [wikipop]XML[/wikipop] file. Microsoft has put out some tools to aid in the creation of these files, namely the Windows System Image Manager. This is part of the Windows Automated Installation Kit (AIK), a rather hefty download (1.6 GB iso), but something you need.

Using WSIM

Once you’ve downloaded and installed the kit, you need to grab some files from your Windows 7 installation disk. Explore the disk, go to the sources folder, and look for a file called install.wim, it’s about 2.5 GB in size. Copy that to your computer somewhere (I put mine in C:\Sysprep, but it doesn’t really matter where you put it). Now go ahead and open the Windows System Image Manager.


A new Windows System Image Manager window

It looks kind of ugly, but once you get used to it it’s not bad. The window is split into a few different sections, we only need the Windows Image, Answer File, and Properties sections. Right click where it says Create or Open an Answer File and hit New Answer File.

Win7-NewAnswerFile
Blank Answer File

So now we have a blank answer file. The seven different options under the Components section correspond to the different passes that Sysprep makes. I’m not going into too much detail now; you don’t need to know a whole lot about the passes in order to get this to work. So for now, right-click where it says Select a Windows image or catalog file and clickSelect. Go to the install.wim file you copied earlier, and hit Open. It will probably tell you that it can’t find the catalog file, and ask if you’d like to make one; click Yes. This will “take a few minutes.”

Components are added to your answers file

Now you should see a tree with two options, Components and Packages. Expand the Components and you’ll see a long list of odd names. These components are the possible settings you can add to your answer file. Yeah, it’s weird. Anyway, if you highlight a component, the Properties pane will show you some of the available settings. You can then highlight a setting, and you’ll get a little more information; usually it just shows you the type of setting it is (boolean, string, etc), but it will warn you if a setting has been deprecated.


WSIM Properties Pane

Right click on a component and you’ll see Add Setting to Pass… 1 through 7, corresponding to the seven passes in the answer file. Some of them are grayed out, but more often than not you’ve got more than one choice. How do you figure out which to choose? Well, it depends on what you want it to do. For instance, putting amd64_Microsoft-Windows-Shell-Setup into pass 4 gives me different settings than if I put it into pass 7.

That’s the basics of WSIM. Microsoft’s TechNet has a more in-depth information about it if you’re interested.

Alright, so what are the Passes?

There are seven configuration passes: WindowsPE, offlineServicing, generalize, specialize, auditSystem,auditUser, and oobeSystem. Each is designed to take care of different parts of the setup process. Microsoft has a nice little table to explain what they do, go ahead and skim through it if you want. What we really need to know is this:

Generalize runs when we run Sysprep /generalize

Specialize runs on the next boot after running /generalize

AuditSystem and AuditUser run when we run Sysprep /audit

WindowsPE runs when Windows PE boots (it’s the setup environment, like what you’d see when you’re first installing Windows)

Making Sense of the Components

You’ve probably noticed that all of the components have very similar names. They all begin with AMD64, x86, or wow64, then Microsoft-Windows, and THEN the name of whatever the component controls. The beginning specifies the architecture that the component is designed for; AMD64 is for 64 bit machines (both Intel and AMD) and x86 is for any 32 bit hardware. [wikipop]WoW64[/wikipop] is short of Windows-on-Windows 64, it’s a subsystem that runs 32 bit programs on 64 bit OS’s (I’m not really sure when their use would ever be needed).

Most of the components have multiple versions, one for each architecture, so make sure to choose the right ones. For this article, I’m using only AMD64 components, but the 32 bit ones are very similar.

Okay, Now Let’s Make an Answer File

So once you’re familiar with using WSIM, all that’s left to do is build the answer file by adding the components you wish to add.

Building a Basic Answer File

To create a basic unattended installation answer file, we need two components: amd64_Microsoft-Windows-International-Core_neutral and amd64_Microsoft-Windows-Shell-Setup_neutral. The two of these take care of the basic questions during setup. Add International-Core_neutral to pass 7, and Shell-Setup_neutral to both 4 and 7.

In Shell-Setup_neutral for pass 4, set:

  • Computer Name: * (this is a wildcard, it will create a random computer name)
  • Copy Profile: false (this doesn’t work the way that we want it to, so set it to false)
  • Time Zone: full name of your time zone (ie Central Standard Time, Saint Pierre and Miquelon Standard Time)

Leave RegisteredOrganization and RegisteredOwner alone, we’ll change those in Pass 71

In Pass 7, you can change the RegisteredOrganization and RegisteredOwner settings. Also notice that you can expand this component in Pass 7, and you’ll see a sub-component named OOBE. Here, you can set:

  • HideEULAPage: true
  • HideWirelessSetupInOOBE: true
  • NetworkLocation: Work/Home/Other
  • ProtectYourPC: 1,2, or 3

Do NOT set SkipMachineOOBE or SkipUserOOBE. SkipMachineOOBE is for “testing purposes only”, and SkipUserOOBE is deprecated;  SkipUserOOBE is referring to the sort of Welcome screen that you’d typically get in previous versions of Windows the first time you log in, but there isn’t anything of the sort in Windows 7, so that setting doesn’t do anything.

On the ProtectYourPC setting, you can set it to be 1,2, or 3. When running setup, you’re asked to choose what sorts of updates you want your computer to automatically download. 1 is equivalent to the recommended setting (all updates), 2is only important updates, and 3 is none.

For International-Core_neutral, there are five settings:

  • InputLocale: Specifies the system input locale and the keyboard layout
  • SystemLocale: Specifies the language for non-Unicode programs
  • UILanguage: Specifies the system default user interface (UI) language
  • UILanguageFallback: Specifies the fallback language if the system default UI language is only partially localized
  • UserLocale: Specifies the per-user settings used for formatting dates, times, currency and numbers

The values are a string that specifies language and country. The naming scheme follows ISO 639-1 (language codes) andISO 3166-1 (country code) standards. For example, if you want everything to be in English and you’re in the United States, you’d use en-us. And if you live at the Vatican and speak Esperanto, it’d be eo-va.

Once all this is added, your answer file should look something like this:

Answer File

At this point, you could save the file to your Sysprep directory, and run Sysprep by going to commandline and typing:

cd C:\Sysprep
Sysprep /generalize /unattend:<unattendfilename>

Once the machine shuts down, take an image, and it’s ready to deploy.

Adding Other Components

Those two components are really all you need to get the unattended installation process rolling, but Sysprep allows for much greater customization during setup. Looking at the components list, if we expand Shell-Setup_neutral, you’ll notice there are a ton of extra sub-components that weren’t listed in the answer file. To add them, just right click and choose what pass you want them in. For example, you can create new user accounts during setup, run logon commands, set display settings, etc.

There are tons of different components, and what each does isn’t very obvious in WSIM. As of writing this, Microsoft doesn’t have a breakdown of the components on their website for 7, but they do have one for Vista. Unless something has been deprecated, it should behave pretty similarly to how it did in Vista’s unattended setup, so it’s a good resource for figuring out how a component works.

Add Device Drivers

Adding new device drivers is now a lot easier than in XP. First, get all the drivers you’ll need all nice and organized somewhere you can get to easily. At the top of WSIM, click Insert, then Driver Path. Choose Pass 5 AuditSystem, because we can’t run the WinPE or offlineServicing passes in Sysprep. Select the folder that you’ve got all of your drivers in, and a new component will be added to the AuditSystem pass: PnpCustomizationsNonWinPE_neutral. Expand the component down to the Credentials sub-component, and provide a user name and password that has access to your drivers folder.

Note that if you do this, you must run Sysprep /Audit /Unattend:<filename> to run the AuditSystem pass. Once this is done, you then need to run Sysprep /OOBE /Unattend:<filename> to perform the remaining passes.

Other Things That Are Worth Noting

Creating Default User Profile

To change the Default User profile, you’ve basically got to manually replace the folder. However, using the Copy To… button in the User Profiles doesn’t work as it did in XP and Vista. The Copy Profile setting in the answer file doesn’t work either.

To get around this problem, first, get your profile setup the way you like it then go to C:\Users. Make a copy of the current Default folder (name it Default.back or something).2 Next, delete the Default folder and rename the profile you just setup to Default.

To test it simply login with another account to be certain that you get the settings you expect. If it doesn’t have the same settings as the one you setup, there might be a permissions error with the new Default folder.

If you get a message such as ‘You have been logged in with a temporary profile’ then it is likely because you are attempting to log on to a profile that wasn’t properly removed.  This article for clearing profiles from registry (for Vista, but don’t let that shake you) did the trick for me.

One thing you’ll probably notice is that the desktop background changes when you do this. This is because by default, the background image is stored in a C:\Users\<profilename>\Roaming\Microsoft\Windows\Themes\TranscodedWallpaper.jpg, and for whatever reason, this doesn’t seem to get copied over.

If you want to persist the same background across all new profiles, you just need to change one registry setting: HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper. Just put your background image somewhere that it won’t be messed with, and point that setting to the new picture. Then, of course, copy this profile back over the Default profile again.

Customize the Login Background

Windows 7 allows you to change the login background without the need to use third-party software like Vista (or maybe I just never figured it out?).

Go to %windir%\System32\oobe. Create a new folder called info. Then, inside info, create a new folder called backgrounds. Inside this folder, you can put your images, at least one named backgroundDefault.jpg. You can add others, named background<resolution>.jpg For instance, I have background1280x1024.jpg and background1680x1050.jpg. Windows will automatically pick the proper image, depending on the screen resolution. If it doesn’t find an appropriate one, it will default to backgroundDefault.

Now, go back to \oobe. Notice there is another background.bmp here. We need to change this too, but it’s considered a system file, so we’ve got take ownership of it first. Type cmd into the Start menu search box, and press Ctrl+ Shift+Enter to open an Administrator command prompt.

Now, type takeown /f c:\Windows\system32\oobe\background.bmp

If it gives you a Success! message, then you’ve got control of the file. However, you still must change the permissions to allow yourself access to the file. Once that’s done, rename the file something else, and then create a new background.bmpwith your login background.

Finally, there’s one Registry key to change: HKLM\Software\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background\OEMBackground. Set its value to 1, and that’s it.

Good Reading

TechNet: Windows 7 Desktop Deployment – a lot of articles about various aspects of Windows 7 deployment. Not the most user friendly setup, but the information is good.

Footnotes

  1. some even claim that you MUST leave these at their default values of “Microsoft” and “AutoBVT”. []
  2. If you do not see a Default folder, you may have to Show Hidden files/folders in Windows Explorer options []
US

17 Responses to “Windows 7 Deployment with Sysprep”

  • allie woodrum:

    We are working in deploying several workstations with windows 7. We are using Windows Deployment Sever (WDS). As for now, we have already accomplish the following

    we can PXE boot the workstations
    connect to the MSD server
    boot with winpe + answer file (formatting the partition that came with OEM system)
    deploy a install.wim image we got from volume licening CD + answer file

    For now we have a pretty much lite touch deployment scenario. But we would like to have the appearance to look as much as possible as XP, so the transition would be smother for the end user.

    So we though about setting up a WS and gave it the looks like XP, and we try copying this profile configurations to the default profile but we couldn’t, we found out that we need to sysprep the WS with the option true, but after the sysprep and generalize, when we restarted the computer it failed.

    message:

    windows failed to load because the HAL is missing, or corrupt

    file:\windows\system32\hal.dll
    0xc000000f

    Any sugestions?

    thanks

  • Michael:

    I would like to point out that the copy profile command does work in the sysprep xml file. I am not sure if Microsoft fixed this recently. Please see this website for a good basic step by step instructions for sysprep use along with some other good tools and tips and tricks. http://blog.brianleejackson.com/sysprep-a-windows-7-machine-%E2%80%93-start-to-finish-v2. I have personally followed this website and have successfully made my image set and it works great.

  • Hmm, looks like he updated that article since I’d last read it.

    After doing some looking about, it looks like people figured out a way to get it to work. Apparently if you have the Administrator account enabled, sysprep will always copy its profile.

    Brian’s blog works great if you’re building a completely new image correctly, and from scratch. Another way around this looks to be just deleting the Administrator profile:
    http://social.technet.microsoft.com/Forums/en-US/w7itproinstall/thread/525dc1f0-0814-4ddd-bca2-b27fa2704871 (8th post down)

    Thanks for pointing this out to me, I’d just assumed it was completely broken. I’ll get it working, and update this post.

    And Allie, sorry for not responding to your post. I’m working on trying to find an answer today.

  • FDC77:

    I’m getting the same Black Screen as Allie. Followed the directions from MS (http://www.microsoft.com/downloads/details.aspx?familyid=901663E1-934F-4793-8EAE-7C0A1CCB83A5&displaylang=en) exactly twice, and both times I am getting a black screen of death if you will after running the sysprep generalize. “Windows failed to load because the HAL is missing or corrupt” This is on a clean install of win7 with nothing else added just to make it simple. Is the generalize blowing away the HAL? it seems like it has happened twice now…

  • I must admit, this is an odd problem.

    In a post on TechNet that Allie made, it was determined that the problem was because 1) the computer wasn’t put into Audit mode before being generalized, and 2) the recovery partition on the particular machine was messing up the Sysprep process somehow.

    As far as I know, I haven’t been putting my machines into Audit, and I don’t know if they have a recovery partition, but I personally haven’t run into this problem.

  • FDC77:

    There is a recovery partition on the machine being that I didnt delete the small partition from the manufacturer… Strange… I did not go into audit mode before generalizing because microsoft’s documentation doesn’t say to do that. I’ll give it a shot and report back.

  • FDC77:

    Amazingly enough. It does seem to be working better now that I purged the OEM partition and did a reboot into audit mode before generalizing. Geez, this would have been nice to know a few days ago, but maybe it will save someone else the time.

  • George Herrick:

    I was following your advice concerning the creation of the default user profile in Windows 7. Here is a problem that I am having though… in the profile that I am using to configure the default profile (the one that I will make a copy of for use as the default user profile) I am configuring several settings in Media Player 12. These settings are being carried over but the default Rip folder does not get set properly. In Vista, there was a registery key I could set to fix this problem, but apparently Windows 7 and Media Player 12 take a different approach. Can you offer any advice as to how I can configure the settings I need to set in MP12 AND have it inherit the proper Rip folder (I want it to default to the user’s Music folder. Thanks in advance.

  • Mikhail:

    Copy Default profile set to True in sysprep xml file didn’t copy the profile for me. I tried many many times but every time that I have the copy option set on True it gives me an error message when processing Specialize Shell menu. As soon as I set it to False – everything works. I tried running sysprep from admin account in Windows 7 and also from admin account being in Audit mode. It doesn’t make any difference – All the settings in the unattend xml file work as long as copy profile is set to false. I even created a very simple unattend file with just this line to copy profile and it didn’t work until I set it to false.
    Manual copy of the default profile is the only option for me.

  • Emma:

    The issues with the hall.dll is simply a boot.ini entry that is incorrect for the machine you are deploying the build to.

    “windows failed to load because the HAL is missing, or corrupt
    file:\windows\system32\hal.dll”

    I have encountered it numerous times. Usually it is the machine you used orginally had an OEM partition – I like to keep the diagnostic partitions, so all of my images are designed to be built onto partition 2.
    If the machine has had a new hard drive, and does not have this OEM diagnostic partition and you do not create a ‘fake’ partition, you will get this unhelpful error message. If you create the ‘fake’ partition and always remember that you shoud install of parition 2 (in my case) you will not encounter this issue.

    Just use imagex to extract image and then edit boot.ini file, to reflect which partition you want windows to be used from – and then stick to it like glue and you will be fine.

  • Christian:

    I need help. I set my default profile to have to French (Canada) with Canadian French keyboard as the default and as the secondary I want English (Canada) with Canadian Multilingual Standard keyboard. Once I sysprep, the keyboards get swapped. So Canadian Multilingual Standard falls under French (Canada) and Canadian French falls under French (Canada). BTW the US English keyboard always gets added as well. I tried setting the languages with proper codes in the unattend.xml. I even removed those components from the XML. Still no luck.

    Any ideas?

  • Christian:

    Oh. Copy profile is set to true.

  • So I ran through sysprep and the image does work but it still asks me to select language/time zone/user account. The user account I had on the image is still there. Can someone email me explicit directions on how to get the usb image to go directly to installation without asking the setup questions. My boss is getting frustrated with the time being spent on this and I’m a tenacious person and want it to work,
    aleblanc@unm.edu

  • Chris Payk:

    I have setup my unattend file and I need to add drivers for 3-4 different hardware models for Lenovo systems. I have added the PnpCustomizationsNonWinPE_neutral under the AuditSystem pass. It looks like it installs the drivers fine, however, I’m not sure about where exactly I need to run the Sysprep /OOBE /Unattend: as mentioned.

    My goal is to have a single image for the 3-4 different models but following this method seems to only allow me to install 1 set of drivers based on the model of the reference computer before I resysprep it to the OOBE.

  • clane:

    I have had mixed success with using “CopyProfile=True” and the local Administrator account. I have found that if I leave the Administrator account disabled & create a new account with Administrator rights and customise that profile, the “CopyProfile=True” line works every time. I find this is much cleaner & simpler than messing with the default profile in Windows 7.I have also come across the error message when processing Specialize Pass/Shell-Setup component Mikhail describes. Through trial & error, I found by removing unneeded lines The error message goes away. In my case it was the line that seemed to cause the problem.

  • clane:

    oops, left out the line details. It was the ComputerName line which I had left blank.

  • @Clane,

    Thanks, I’ll give that a try in a few weeks when we re-image our laptops. I agree that messing with the default profile is really messy, I’d love to let Sysprep handle it.

Plugin from the creators ofBrindes :: More at PlulzWordpress Plugins