Feb 2, 2011

How To Sysprep Windows 7 On The Easy

As some of you know that have been following me on Twitter, or Facebook, I have been setting up a new OS/Software deployment server using Fog. The cool thing about Fog, besides it is free, and runs on Linux is that it is ridiculously easy to implement, and put into production. My boss originally had me try to use Microsoft System Center Configuration Manager (SCCM) but that thing is such a bear to deploy. Especially in a multi-domain environment like I maintain, something domain agnostic (and free) simply works better.
Now, since Fog is a cloning solution like Symantec Ghost Cast, you take an old fashion image of a computer which we all know is hardware specific. What's cool with Fog though is that you only need to image the operating system with drivers and updates. All other software can be deployed with Fog separately, making it easy to keep your image software up to date.
Since we are creating an image, we need to Sysprep right? I have spoken to a lot of admins, and running Sysprep in Windows 7 causes gasps, cold sweats and nightmares. Everybody knows that Sysprep for Windows XP was a piece of cake, but for Windows Vista and Windows 7 Microsoft came up with the Windows Automated Installation Kit (WAIK) tool. Lets be honest here, using the WAIK tool is about as intuitive as trying to find the wet spot on a fat chick.
So WAIK sucks. I think we can all agree on that. We still need to Sysprep though. According to Wikipedia, here's why:

Windows operating system installations include many unique elements per installation that need to be "generalized" before capturing and deploying a disk image to multiple computers. Some of these elements include:
  • Computer name
  • Security Identifier (SID)
  • Driver Cache
Sysprep seeks to solve these issues by allowing for the generation of new computer names, unique SIDs, and custom driver cache databases during the Sysprep process.
So how to we go about doing this without having to screw around with WAIK? Glad you asked! First of all, my process is really easy to do, and once you do it, you never really need to do it again. The trick with Windows 7 sysprep, as with Windows XP, is creating the answer file. Once it's created, you can use it over and over again.
What you will need:
  • Windows Automated Installation Kit (Yes you still need it, but bare with me)
  • Windows 7 Installation Media
  • RT Se7en Lite
Before I go further, don't be scared of WAIK. It has to be installed on the same machine as RT Se7en Lite because RT Se7en Lite uses WAIK as the engine to do what it has to do. It also provides you an easy to use intuitive interface to do what you have to do which is to create an XML answer file for Sysprep.
Here is what you need to do:
  • Open RT Se7en Lite, and point it to your Windows 7 Installation Media
  • Click the Tasks button and select Export XML and Save Settings from the Quick Start Drop Down
  • Uncheck ISO bootable (You don't need it for this post)
  • Click on the Unattended button
  • On the General tab, Check all of the boxes (including skip product key as it doesn't work) then fill in the information to fit your environment
  • Click on the OOBE tab
  • Check all the boxes except Disable Auto Daylight Savings Time Set (Unless you live where daylight savings is not recognized), and change the Network Location and Security Updates settings according you your environment
  • Click on the Regional tab, and choose your regional information
  • Click the Export button on the lower right, then check the box to explore the generated XML directory
  • Boom! Your new Autounattend.xml file will be located in the root of your Windows 7 Installation media.
Okay, that was the hard part. Doing that in WAIK by itself is way more difficult! RT 7 Lite makes it stupidly easy! You're not done yet though. You still have to do a couple of things. Before we go further, go ahead and make a batch file called SetupComplete.cmd. Actually, you can name it whatever you want, but lets keep it simple. In SetupComplete.cmd paste the following commands:
del /Q /F c:\windows\system32\sysprep\Autounattend.xml
del /Q /F c:\windows\panther\Autounattend.xml
echo Sysprep Completed %date%>c:\ImageLog.txt
cscript //b c:\windows\system32\slmgr.vbs /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
cscript //b C:\windows\system32\slmgr.vbs -ato
As you can probably guess, you will need to change the X's above with your Windows 7 product key. Once you have that saved in SetupComplete.cmd, on the machine you want to image create create a folder in c:\windows\setup called scripts and drop SetupComplete.cmd in there. The reason is because after Sysprep does it's thing it runs any script in the folder. SetupComplete.cmd cleans up our XML answer file with sensitive passwords, creates a log on the root of C:\ called ImageLog.txt then inserts our Windows 7 key. Now you can try adding your Windows 7 key to your XML file using RT 7 Lite, but trust me, it doesn't work. My method with the script does.
Now that SetupComplete.cmd is in c:\windows\setup\scripts, take Autounattend.xml that we created earlier and drop that sucker in c:\windows\system32\sysprep. Now we are almost out of the woods. Open a command prompt in c:\windows\system32\sysprep by pressing shift and right clicking in the white space (assuming you are in that directory using Windows Explorer) and select Open Command Window Here. Now with command prompt open in the sysprep directory run the following command and crack open a cold one:
sysprep /generalize /oobe /shutdown /unattend:Autounattend.xml
Sysprep will do its thing using your answer file, then shut down. Your computer is now ready to be uploaded using whatever imaging solution you use! Tell me that wasn't easy!
Do you know of a better way to create the XML file for Sysprep? I would really like to not have to use the cscript command, however it is still better than trying to screw around with WAIK! If you know of a better tool that makes this process easier, let me know in the comments!
NOTE: If you want to join your computer to your domain, add the following command to your SetupComplete.cmd file right after del /Q /F c:\windows\panther\Autounattend.xml:

I didn't mention that above because I use Fog to join my machines to the domain for me.

Twitter Delicious Facebook Digg Stumbleupon Favorites More

Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | stopping spam