You are on page 1of 19

Windows Integration Guide

There are different methods to integrate (languages, updates, drivers, etc ...) in Windows.
Offline integration is usually done by mounting a disk image and adding things to it.
Standard methods would be:

Windows Automated Integration Kit (WAIK) for Windows Vista and Windows 7

Windows Assessment and Deployment Kit (ADK) for Windows 8 or Windows 8.1 Update

DISM commands for ALL versions of Windows

Online integration is usually done by adding a file or series of files to a computer system while the
computer is running (online). It does not refer to the connectivity of internet.
Prepare/Capture is commonly referred to as sysprep/audit mode.
It is most frequently accomplished by preparing a Windows install using Audit mode.
You can enter Audit Mode on most Windows Setups by pressing ctrl-shift-f3 while at the user creation
screen. It will set a status file %windir%\setup\state\state.ini to reflect booting into Audit Mode and
reboots the system immediately. When finished preparing the system, the user generally runs a Sysprep
program that wipes certain registry settings and user information to prepare the drive to be captured
for an install image.
Sysprep will change the Audit Mode back to the normal setup mode if you select the OOBE option (Outof-box Experience).
You can also enter Audit-Mode by running admin command prompt and navigating to
%windir%\system32\sysprep\ and running the command:
sysprep.exe /audit.

Basics of Offline integration


What you need:

An editable install image such as install.wim, boot.wim, or winpe.wim

A few folders to work with (mount, integration, temp)

DISM, WAIK ,or ADK

Mount the disk image. You can do this from admin command prompt by running command:
Dism /mount-wim /wimfile:c:\win81\sources\install.wim /index: 1 /mountdir:c:\mount
Make your changes. Mostly this involves setting a product key, adding a MSU or CAB file, or copying
something over to your image.
To set a product key in dism, you use admin command prompt again with a command such as:
Dism /image: c:\mount /set-productkey: XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
To add a MSU or CAB package such as a kb file that you download from Microsoft Download Center or
Windows Update Catalog, you use command:
Dism /image: c:\mount /add-package /packagepath:c:\integration\kbfiles\x86
To copy things to your install disc, such as a driver directory, you have many options.
You could manually copy a directory to a mounted image directory. You could also automate it with a
few commands such as:
Mkdir c:\mount\Drivers
xcopy c:\integration\Drivers\* c:\mount\Drivers\ /cherkyi
that command will copy the contents of "c:\integration\Drivers\" and any subdirectories and files. This
is useful for a script. You can also delete files that you don't want on the Install, though I recommend
against it if you don't know what you are doing. I typically work with a couple commands:
Del c:\mount\somefileiwannadelete.txt /y or rd /q/s c:\mount\somedirectoryiwannaditch
unmounting the disk image. You can choose to save your changes or discard them with the commands:
Dism /unmount-wim /mountdir:c:\mount /commit or
Dism /unmount-wim /mountdir:c:\mount/discard
The discard command will clear all the files out of the mount directory and disregard any changes. That
is, they will not be saved back into the WIM file.
So, a simple script with some of these commands strung together could give you a basic offline
integration:
dism /mount-wim /wimfile:c:\win81\sources\install.wim /index:1 /mountdir:c:\mount
dism /image:c:\mount /set-productkey:XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
dism /image:c:\mount /add-package /packagepath:c:\integration\kbfiles\x86
mkdir c:\mount\Drivers
xcopy c:\integration\Drivers\* c:\mount\Drivers\ /cherkyi
dism /unmount-wim /mountdir:c:\mount /commit
You would make a text file and save it as a file such as: Integrationx86.cmd

The CMD extension lets you run the file from Windows as a script. You then simply run the script as
Administrator to go through the
entire set of commands.

Basics of Online Integration


What you need:

An online system capable of working with the version of dism and files that you are trying to
integrate

Folder with the files you need to integrate

DISM

No need to mount. The whole idea behind online integration of things is that it's only used for installing
system files or features. In this case, the operating system is running, so you don't mount anything. So
you skip the parts in the offline integration that have to do with mounting and replace certain parts of
the dism call.
Integration. This is done on an online image by replacing the /image call with /online.
This is most commonly done with Windows 8 and Windows 8.1 to enable NetFx3 from an install media:
dism /online /enable-feature /featurename:NetFx3 /all /limitaccess /source:X:\sources\sxs
In this case, the X:\sources\sxs is the sxs folder on a Windows 8.x mounted ISO file. You would replace
the X with the actual drive
letter of the mounted ISO file. The /all command tells it to add all sub-features. The /limitaccess
command tells it to not try
to connect to Windows Update to download the feature files from the Update Servers. This is useful for
the month or two after a
new Windows version such as 8.0 or 8.1 has become available and they haven't yet enabled the online
portions.
There's not much else you can do in /online mode; at least I haven't done anything else. MSU files are
not integrated with DISM while
online, and you set the productkey with SLMGR. TO integrate online updates you use the WUSA
program that's built into Windows.
To do online integration of all MSU files in the same folder as a script, you edit a text file to contain this:
@echo off
pushd %~dp0
for /f %%A in ('dir /b *.msu') do (echo == Installing Updates == "%%A" ...
C:\Windows\system32\wusa.exe %%A /quiet /norestart)
echo.
echo ########################################
echo.
echo == Updates installed ==
echo.
echo == Press any key to restart ==&pause>nul
echo.
shutdown.exe /r /t 0
You don't have to have the echo or restart commands, but it helps to keep track of your progress. Since
you always have to restart on adding a few kb files with WUSA, it's there for a reason. This script

searches the current directory for any .MSU files and installs them with WUSA. You run this command as
admin by right clicking the script and selecting run as administrator.

Prepare/Capture
Commonly referred to as Audit/Sysprep is simply preparing an online OS in a way that you can install it
later, possibly on another computer.
What you need:

An extra drive or partition to work with.

Stuff to add

A capture method

Start Windows Setup from boot and select the partition where to install.
Let Windows Proceed until the User Creation Screen. At this point you enter Audit Mode by pressing
CTRL-Shift-F3, Windows will reboot and skip the user creation process. When you finally boot into your
installed OS, you will be greeted by a sysprep window.
Just ignore that for now.
Add drivers, updates and your personal settings (the directx runtimes, any Netfx updates, latest hotfix
files from Windows Updates, perhaps a WinRAR or 7-zip, maybe a bunch of Visual c++/basic updates.
You can also add things such as Microsoft Office.
"Additional info about Win8.x audit-mode:
Win8.x has a unique issue with Windows Update. It doesn't like to let you use it during Audit-Mode use.
So to get around this problem, you create a user like you normally would, but then reboot into auditmode and delete that user before capturing.
For example, in order to do a simple win8.x Windows Update sysprep/capture integration, the steps
would be something like:
1) Install Operating system and create a generic user. It doesn't matter what settings you use or what
you name the account
2) Run Windows Update from within win8.x (If very old versions of win8.x, you might need to either
reboot once or run admin prompt
command "net stop wuauserv" that will kill a bug that existed where the Windows Update application
wuapp.exe will seem like it is updating, but will never actually do anything. You can simply re-check for
updates after stopping the service once
3) Update all of your Windows Update hotfixes, updates, and whatever else you wish to add to
Windows
4) Run %windir%\system32\sysprep\sysprep.exe /audit as admin
5) Once in audit mode, go into user accounts and delete the account you made to install updates and
programs
6) Clean up temporary files such as extra directories created to store install files (c:\amd or c:\nvidia,
vcredist folders, etc) You can also
delete %windir%\softwaredistribution folder. That folder is created when you first run Windows Update,
and is not actually necessary for further use
7) Delete both the temporary account and admin account folders in the \users\ folder. (You don't need
them at all)

That's it for win8.x advice".


Finishing up your Audit-Mode: Now that you're all done, make sure you reboot and cleaning up your
disk. When you're confident, give it one more reboot before you proceed.
Now you use your sysprep window that you were ignoring. You have a few choices, but the only thing
that will need will be the generalize option.
What Generalize does is try to scrub the registry hives of any user related information such as recently
opened files, or Administrator specific tags.
It also deletes the current machine's hardware configuration.
The only reason I wouldn't use Generalize is if you are going to be the only person to use this Windows
Setup and your computer will never change hardware. If you plan on upgrading any hardware, go ahead
and check the box to enable Generalize. Let sysprep proceed - It will mention running cleanup tools and
then it will either reboot or shutdown depending on your options.
IMPORTANT:
When you reboot, make sure you choose the 2nd boot option. The first one will be the newest installed
OS. In your case, it will be the newly sealed SYSPREPPED drive.
Now you be booted back into your Main OS. It's time to further prepare your drive a bit.
Navigate to your sysprepped partition from the explorer. It's ok to look around in there, just don't try to
install stuff there. Delete the users\administrator\ folder. This is not used any longer. That's it, you're
ready to capture.
Capture the image: Here you have a few options. You can use DISM, ImageX, GImageX v2
I personally use GImageX v2. You simply choose the Source drive the "sysprepped one".
Set the destination file: c:\temp\install.wim will suffice, or set to an existing install.wim if you want to
append to the image. Set all 4 description areas, name/desc and display name/desc.
Change the compression to Maximum.
Choose either create or append depending on whether you want to create a new install.wim or add to
an existing one.
When you start creating, depending on the OS version you are capturing, it might take quite a long time.
If you have a lot of files on a Windows 8.x system, it will take probably an hour or longer.
If you are capturing a Vista or Win7 system it will be substantially faster.
This is because of the limitations of imagex and the WIM format. It gives a LOT of warnings that you
cannot save extended file information in the WIM format. It gives a warning for every system file and
will take quite some time before it stops scanning and actually starts capturing. Be patient.
So here's an example command for dism capture:
dism /capture-image /imagefile:c:\temp\install.wim /capturedir:X:\mount /name:"Windows x.x 32bit" /description:This part will show at the bottom of the screen after selecting the index during
setup" /compress:max /checkintegrity /verify

Make an ISO file using that modified integration image


What you need:

A substitute folder for which you will replace the install.wim

oscdimg, tool available in WAIK tools folder

Substitute folder: Extract the ISO you used as a starting point to a folder. Ex: C:\win81\
Now, if you did a sysprep/capture, replace the install.wim and you're ready to create the ISO.
If you did an offline integration, you might want to re-compress the install.wim. If you add a lot of MSU
files it can save a few hundred megas. The way you re-compress an install.wim is by creating a new one
and exporting all the images to it. You can use the export tab of GImageX v2 or use imagex from the
WAIK tools. An example of a re-compression would be something like this:
imagex /compress maximum /export c:\win81\sources\install.wim * c:\temp\install.wim
move /y c:\temp\install.wim c:\win81\sources\
oscdimg: The tool you should use to create an ISO file with a boot sector is called oscdimg.exe and it's a
commandlinetool that you get in the WAIK tools folder.
oscdimg -bc:\win81\boot\etfsboot.com -u1 -lWin81DVD c:\win81\ c:\temp\OutputDVDName.iso
More dism command information can be found on technet:
http://technet.microsoft.com/en-us/library/hh825258.aspx

Advanced Integration Topics


Advanced Topics
This list may vary over time if I need to add/remove things or change things around.
I plan on making a few points here:
1) Manually prepare a disk using diskpart or diskpart import script
2) ProWMC conversions and Windows 8.x activation restoration on fresh ProWMC installs
3) AIO creation, scripting methods, Do's and Don'ts
4) Different KBfile integration methods and setupcomplete.cmd scripting
5) Win8.x install.esd compression (Saving Space)

1) Manually prepare a disk using diskpart or diskpart import script


Configuring a MBR partitioned drive is a bit different than configuring a GPT partitioned drive.
Here are some reference technet articles:
For mbr:
http://technet.microsoft.com/en-us/library/hh825677.aspx
For gpt:
http://technet.microsoft.com/en-us/library/hh825686.aspx
You have 2 choices for each partition scheme, and none of them include Windows XP or Vista support.
It might be possible to support dual-booting to Vista and XP, but you need to install them first as they
don't have native system partition support. In Windows 7/2008server they started adding a 100mb
system partition for storing certain things. I don't know all what is stored on them. I know that defender
updates are stored there. Probably registry settings as well. Anything beyond defender updates is just
speculation from me.
The choices for each method are whether or not you want to include a recovery partition.
MBR diskpart script for no recovery partition is:
select disk 0
clean
create partition primary size=350
format quick fs=ntfs label="System"
assign letter="S"
create partition primary
format quick fs=ntfs label="Windows"
assign letter="W"
exit
MBR diskpart script for recovery partition is:
=====================================================
rem == CreatePartitions-BIOS.txt
rem == These commands are used with DiskPart to create
rem == three partitions for a BIOS/MBR based computer.
rem == Adjust the partition sizes to fill the drive as necesary.
=====================================================
select disk 0
clean
=====================================================
rem == 1. System partition
=====================================================
create partition primary size=350
format quick fs=ntfs label="System"
assign letter="S"
active

=====================================================
rem == 2. Windows partition
=====================================================
rem == a. Create the Windows partition.
create partition primary
rem == b. Create space for the recovery image.
rem == Note, adjust the size to match the size of the recovery image.
shrink minimum=15000
rem == c. Prepare the Windows partition.
format quick fs=ntfs label="Windows"
assign letter="W"
=====================================================
rem == 3. Recovery image partition
=====================================================
create partition primary
format quick fs=ntfs label="Recovery image"
assign letter="R"
set id=27
list volume
exit
For GPT without recovery partition diskpart script is:
select disk 0
clean
convert gpt
create partition primary size=300
format quick fs=ntfs label="Windows RE tools"
assign letter="T"
rem == Note: for Advanced Format Generation One drive
rem == change to size=260.
create partition efi size=100
format quick fs=fat32 label="System"
assign letter="S"
create partition msr size=128
create partition primary
format quick fs=ntfs label="Windows"
assign letter="W"
For GPT partition WITH recovery partition it's:
=====================================================
rem == CreatePartitions-UEFI.txt
rem == These commands are used with DiskPart to
rem == create five partitions for a UEFI/GPT-based PC.
rem == Adjust the partition sizes to fill the drive as necessary
=====================================================
select disk 0

clean
convert gpt
=====================================================
rem == 1. Windows RE tools partition
===============================================
create partition primary size=300
format quick fs=ntfs label="Windows RE tools"
assign letter="T"
set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
gpt attributes=0x8000000000000001
=====================================================
rem == 2. System partition
=====================================================
rem == Note: for Advanced Format Generation One drive
rem == change to size=260.
create partition efi size=100
format quick fs=fat32 label="System"
assign letter="S"
=====================================================
rem == 3. Microsoft Reserved (MSR) partition
=====================================================
create partition msr size=128
=====================================================
rem == 4. Windows partition
=====================================================
rem == a. Create the Windows partition
create partition primary
rem == b. Create space for the recovery image.
rem == Note, adjust the size to match the size of the recovery image.
shrink minimum=15000
rem == c. Prepare the Windows partition =========
format quick fs=ntfs label="Windows"
assign letter="W"
rem === 5. Recovery image partition ================
create partition primary
format quick fs=ntfs label="Recovery image"
assign letter="R"
set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
gpt attributes=0x8000000000000001
list volume
exit
Note that the recovery partitions are at the end of the primary hard disk and that they are created by
shrinking the primary partition. You could change the size of the shrink minimum to save a smaller
amount of room or larger amount of room. If you get real good with creating recovery partitions you

could make them very small and thus use up less room. This is not incredibly important for large
magnetic hard disks, but it can be very beneficial on smaller SSD hard disks.
The way you can use these scripts varies:
You can either create a script on a USB flash drive and thus call the script using something like this,
where F is the letter of the USB flash drive to partition the drive:
DiskPart /s F:\CreatePartitions.txt
or
you could use something like this, and put the MBRNOREC.txt along with a few other diskpart scripts on
the boot.wim index:2 root.
Diskpart /s X:\MBRNOREC.txt
Why would you want to put it there on X:?
Because that's where the command prompt defaults you to when you press Shift-F10 during setup. So if
you already had the files there, you wouldn't need to fumble around trying to find your files before you
apply them. You could also use this to your advantage making a choice script to decide which diskpart
txt script you want to run diskpart /s with.
Using a script to apply different schemes is incredibly useful for setting up different OS versions to their
default sizes. You never NEED to use a smaller system partition, but you could match them up with the
default ones that Windows Setup creates for certain OS versions.
Here's a list of sample MBR "SYSTEM" partition sizes:
Windows 7/SP1 and Server 2008/R2:
100MB system
Windows Server 2011 SBS Standard/Essentials and Home:
100MB system, 50GB Windows partition, 100GB minimum data partition
Windows 8/Server2012:
300MB system
Windows 8.1/Server2012r2:
350MB system
Now that you can manually partition your primary drive, how do you apply the image and get it ready to
run?
OK, putting the diskpart txt scripts in the boot.wim index 2 is a neat shortcut but if you make a script to
apply images, you'll need to know where the disk with the sources\install.wim or sources\install.esd is.
I'm sure a lot of people would have a very short solution, but I'd probably use something like this:
if exist d:\sources\install.wim set MYIMAGE=d:\sources\install.wim
if exist d:\sources\install.esd set MYIMAGE=d:\sources\install.esd
if exist e:\sources\install.wim set MYIMAGE=e:\sources\install.wim
if exist e:\sources\install.esd set MYIMAGE=e:\sources\install.esd
and so forth until z: Then you could call up the path to the image using the %MYIMAGE% tag instead of
messing with a faulty small loop that may or may not get it right.
Now, to apply the image, you do something such as:
Dism /apply-image /imagefile:%MYIMAGE% /index:1 /ApplyDir:W:\

That would be your Windows partition, and hence why you would apply the image to that partition.
Now, Make sure your "SYSTEM" partition (not Windows partition) is set to Active if you are using MBR
partition format.
This is done by using the "Active" command after creating the system partition.
An example where this is done correctly would be:
format quick fs=ntfs label="System"
assign letter="S"
active
This is important if you want your system to be bootable.
To make said system partition bootable, you run the following command:
W:\Windows\system32\bcdboot W:\Windows
It copies the files from W:\Windows to the system partition. You can also use the /l argument to change
the boot information language.
bcdboot w:\Windows /l en-us would set it to English - United States. es-es would be Spanish. pt-br
would be Brazilian Portuguese, and so on.

2) ProWMC conversions and Windows 8.x activation restoration on fresh ProWMC installs
To create a Pro with Media Center index in your install.wim, you use a dism /set-edition command. First
you need to locate your Pro index, usually Index:1 of a Windows 8.x Multiple Editions MSDN ISO. To set
the edition, first you need to make sure you are using 8.1 dism if you are
working on an 8.1 ProWMC.
For 8.0 you can use either 8.0 or 8.1. The dism command to change the edition would be something like
this:
dism /mount-wim /wimfile:c:\win81\sources\install.wim /index:1 /mountdir:c:\mount
dism /image:c:\mount /set-edition: ProfessionalWMC
dism /unmount-wim /mountdir:c:\mount /commit
Now you have changed your Windows 8.1 Pro image to a ProWMC edition, but you haven't changed the
name or the flag with which the install.wim will handle the image. The install.wim still thinks it's a
Windows 8.1 Pro image. And why wouldn't it? It doesn't read the image to find out which edition
it is set to. It is pre-defined when creating the image. So you have to use imagex to change the flags and
description.
I use the following command:
imagex /flags "ProfessionalWMC" /info c:\win81\sources\install.wim 1 "Windows 8.1 Pro with Media
Center" "Windows 8.1 Pro with Media Center"
The second copy of the name sets the description. You could use some big long diatribe if you wanted
to. I keep it the same as the index name to avoid confusion.
After those two things are done, the dism /set-edition, and the imagex /flags "ProfessionalWMC" with
the /info line, you now have afull-fledged ProWMC index. It's saved to your old spot that you had Pro in,
so if you still need Pro, you need to export things around and create a new install.wim.

I'll discuss creating a new exported install.wim in the next AIO section.
To restore activation on a ProWMC fresh install, you need to know a few things.
1) What the activation files are.
2) Where they are.
3) What Windows version you are using.
4) Whether or not it's worth saving.
The Windows 8.0 activation files are located in the directory:
c:\windows\system32\spp\store\
They are data.dat (hidden) and tokens.dat
In Windows 8.1 the directory is:
c:\windows\system32\spp\store\2.0
The files are also data.dat (hidden) and tokens.dat
Should I try to save these if I'm upgrading my system?
Well it depends how much you are changing. If you are putting more ram in your system, sure.
If you are changing a video card, absolutely.
If you are changing an entire motherboard, ram, and cpu, absolutely not. Don't bother trying to save it.
To save/restore the activation, simply copy the data.dat and tokens.dat from the store or 2.0 directory
and replace them on a fresh install. Simply copy them over the old files after installing directly to a fresh
ProWMC install. If no hardware changes have occurred in your system, there should still be enough
room in the slop to allow for different UUID or GUIDs or whatever else Windows uses to track things to
make sure you aren't trying to copy activation files to a completely different system. A common myth is
that you have to disable internet when working with activation files. This is false. You simply copy them
over the old ones. You can do it manually or with a script. As long as the SPP service is not currently
running, it will allow the copy. If SPP service is running, just wait like 30 secs and then try again.
After copying over the old files, just do yourself a favor and reboot. You don't have to, but with the way
that the cache stores things in memory it could be a little iffy when or how the system starts to realize
that you have activated files. Alternatively you could fumble around with different system screens until
it re-reads your system files, but it's faster and safer to just reboot.

3) AIO creation, scripting methods, Do's and Don'ts


To create a new install.wim it's surprisingly easy, there's a program called GImageX v2 that takes all the
work. You can simply mount a disc, open GImageX v2, click the export tab, chose the mounted image,
set the index number, change the compression to maximum, and set the export file name.
The trick to exporting images is that you cannot change the order of them once they are in an image. To
change the order you have to delete one of the indexes and add on afterward, or re-export the indexes
to a new image. It sounds more complicated than it is once you get used to actually using the different
index names rather than the concept of exporting.
Say you want to make a baseline image using Win8.1 Pro/Core/CoreSL/ProWMC.
First you decide which order you want them to go in. I usually start with the lesser versions like Core
first, to the more advanced versions like ProWMC or Enterprise. So export your first index to say
C:\temp\install.wim, choose the Core index and export it to the new file. The first export will take the

longest, provided most of the images are the same. After the first one, they will be very quick. then
export CoreSL, Pro, ProWMC.
Now you'll have them all in a neat line:
Windows 8.1
Windows 8.1 Single Language
Windows 8.1 Pro
Windows 8.1 ProWMC
But you know what doesn't look right for an AIO?Well there's two things.
You don't want an index simply named "Windows 8.1" People won't know that's the Core SKU.
Also, what architecture is the index?
If you are going to add both x86 and x64 versions, as many people do, you want to let people know very
clearly which version they are using.
You could use gimagex for this as well but it's fairly easy to use imagex.
Do commands something like this:
imagex /info c:\temp\install.wim 1 "Windows 8.1 (Core) x86" "Windows 8.1 (Core) x86"
imagex /info c:\temp\install.wim 2 "Windows 8.1 (Core) Single Language x86" "Windows 8.1 (Core)
Single Language x86"
imagex /info c:\temp\install.wim 3 "Windows 8.1 Pro x86" "Windows 8.1 Pro x86"
imagex /info c:\temp\install.wim 4 "Windows 8.1 Pro with Media Center x86" "Windows 8.1 Pro with
Media Center x86"
Now you'll have your install.wim, but you have to transplant it over an appropriate setup image. Cut the
install.wim and navigate to your win81x86\sources\ folder. Paste it and overwrite the old one. You could
re-iso the file as I do using oscdimg so that you can load it in a VM or just use it as an unmodified image
AIO where nothing is integrated. To do this run the oscdimg commands from previous post. Note the
UEFI boot recommendation for x64 setup images.
If you use both x86 and x64 versions in a single AIO, you must to use x86 setup files. You can boot and
install an x64 image from an x86 setup disc if only the install.wim is changed, but you cannot always
setup x86 versions from an x64 setup disc.
What if the processor only has 1 core? It's generally bad practice to mix setup versions and try to use
x86 setup files for every AIO, so try to make an x86 version and an x64 version. The amount of
headaches you'll save with people who are trying to do "Repair your computer" or Full upgrading
from a previous OS will be enough to make it worth the extra disc.
You shouldn't try to stuff everything on one disc as a general rule. Leave x86 on an x86 disc, and leave
x64 on an x64 disc.
Well, when you get more practiced at AIO making, you can have something like 18 images or more for a
single disc.
Then if you are making both x86 and x64 versions, you can create a master script that calls two subscripts. That is a good way to log your progress from the dism logging.
You can integrate all the images in a loop, which is the best and cleanest way to handle it. Or you can
simply copy/paste each loop iteration for each index and change the numbers. I'll give you an example
from my recent 8.1 AIO scripting:
x86 script is:
@echo off

if not exist c:\win81x86 exit


if not exist d:\mount mkdir d:\mount
for /l %%x in (1, 1, 7) do (
dism /mount-wim /wimfile:c:\win81x86\sources\install.wim /index:%%x /mountdir:d:\mount
dism /image:d:\mount /add-package /packagepath:e:\win81slipstream\kbfiles\x86\
if exist d:\mount\windows\setup\ mkdir d:\mount\windows\setup\Info
xcopy e:\win81slipstream\Info\* d:\mount\windows\setup\Info /cherkyi
dism /image:d:\mount /cleanup-image /startcomponentcleanup /resetbase
dism /unmount-wim /mountdir:d:\mount /commit
dism /export-image /sourceimagefile:c:\win81x86\sources\install.wim /sourceindex:%%x
/destinationimagefile:c:\win81x86\sources\install.esd /compress:recovery
)
del /q /s c:\win81x86\sources\install.wim
oscdimg.exe -bc:\win81x86\boot\etfsboot.com -u2 -h -m -lWin81AIO-7in1-x86 c:\win81x86\
d:\Win81AIO-7in1-x86.iso
and x64 version is:
@echo off
if not exist c:\win81x64 exit
if not exist d:\mount mkdir d:\mount
for /l %%x in (1, 1, 7) do (
dism /mount-wim /wimfile:c:\win81x64\sources\install.wim /index:%%x /mountdir:d:\mount
dism /image:d:\mount /add-package /packagepath:e:\win81slipstream\kbfiles\x64\
if exist d:\mount\windows\setup\ mkdir d:\mount\windows\setup\Info
xcopy e:\win81slipstream\Info\* d:\mount\windows\setup\Info /cherkyi
dism /image:d:\mount /cleanup-image /startcomponentcleanup /resetbase
dism /unmount-wim /mountdir:d:\mount /commit
dism /export-image /sourceimagefile:c:\win81x64\sources\install.wim /sourceindex:%%x
/destinationimagefile:c:\win81x64\sources\install.esd /compress:recovery
)
del /q /s c:\win81x64\sources\install.wim
oscdimg.exe -bc:\win81x64\efi\microsoft\boot\efisys.bin -pEF -m -u2 -udfver102 bootdata:2#p0,e,bc:\win81x64\boot\etfsboot.com#pEF,e,bc:\win81x64\efi\microsoft\boot\efisys.bi
n -lWin81AIO-7in1-x64 c:\win81x64\ d:\Win81AIO-7in1-x64.iso
I would call them using a master script such as:
call "e:\win81slipstream\Integrate-AIO-x86.cmd"
call "e:\win81slipstream\Integrate-AIO-x64.cmd"
but to also log it, you could use:
call "e:\win81slipstream\Integrate-AIO-x86.cmd">c:\temp\aiox86.log
call "e:\win81slipstream\Integrate-AIO-x64.cmd">c:\temp\aiox64.log
And then you could run the master script as admin and just go to sleep. Now 8.1 doesn't have enough
KB files to bother making a sleep script, but 8.0 does, and if you set up a script similar to the ones I listed

for my 8.1 using 8.0 files, it would definitely fill up a night. You simply extract your baseline
image to the appropriate directories you list in your script. I use win81x86 and win81x64 respectively so
that I'll remember where to put them and I don't make simple mistakes. It happens more than you'd
think if you use long complex directory names, especially ones with spaces where you need to
remember to use quotation marks.
Aside from the index preparing and scripting of integration, that's all there really is to it other than
testing. Believe me, you want to test your work.
Simple mistakes such as accidentily exporting your x64 image to your x86 folder or having dism fail to
integrate kb files past a certain problem file, are common. Which brings up the last topic.

4) Different KBfile integration methods and setupcomplete.cmd scripting


Certain KB files only integrate well when the system is running.
While the system is running, you use a program called WUSA instead of Dism.
But how would you integrate something you cannot integrate offline?
The answer is a setupcomplete.cmd script.
Windows will run C:\windows\setup\scripts\setupcomplete.cmd after all other parts of setup are
finished, if it exists. You should to simply copy over a script.
But you can't simply copy a script without copying the files you want to integrate as well, can you?
Well, there's 2 ways to tackle this beast. The most common way is an $oem$ folder.
Basically you simply make a new directory structure that looks like this:
$oem$\$$\Setup\Scripts\
Then inside the scripts folder, make a setupcomplete.cmd and copy certain files.
I'll use an example from Windows 8.0 which has a problem servicing stack update that causes problems:
:KB2871777 Servicing Stack update
WUSA Windows8-RT-KB2871777-x86.msu /quiet /norestart
:CLEANUP
cd\
shutdown /g /t 5
rd /q/s %WINDIR%\Setup\Scripts
Everything past the : is a notation and is not processed. It's a good way to keep notes so you don't screw
something up. The shutdown /g /t 5 command simply saves the registry and reboots in 5 seconds. Note
that I've deleted the scripts folder as the last line of the script. You have to do this because it cannot run
anything in the script past that point. The reason is simple, it doesn't exist anymore.
So, the reason I do this, is that that particular KB file does NOT like offline integration. You CAN integrate
it, only if it's the last thing you integrate, and it can cause problems trying to later integrate things
during the script, so I do it here; and then reboot since windows needs to config-mode to finish the
servicing stack update.
You copy the entire $OEM$ folder to your setup disc's sources\ folder.

You don't have to use the $OEM$ folder structure necessarily. You can simply mount the index and copy
the files to the mount\windows\setup\scripts folder. This is the way I do it since the scripts I run
sometimes vary from index to index. It's hard to have one index that is not activated, and then have the
next one be pre-activated if you use an $OEM$ folder structure, because it will run the one and only
script present. It doesn't discriminate.
So I've taken to having multiple $OEM$ folder structures that I save in my integration folder and use an
xcopy command.
It goes something like this:
dism /mount-wim /wimfile:c:\win80x86\sources\install.wim /index:1 /mountdir:c:\mount
if not exist c:\mount\windows\setup\scripts mkdir c:\mount\windows\setup\scripts
xcopy e:\OEM\x86\$oem$\$$\setup\scripts\* c:\mount\windows\setup\scripts /cherkyi
dism /unmount-wim /mountdir:c:\mount /commit
dism /mount-wim /wimfile:c:\win80x86\sources\install.wim /index:2 /mountdir:c:\mount
if not exist c:\mount\windows\setup\scripts mkdir c:\mount\windows\setup\scripts
xcopy e:\OEM\PAx86\$oem$\$$\setup\scripts\* c:\mount\windows\setup\scripts /cherkyi
dism /unmount-wim /mountdir:c:\mount /commit

So in my baseline image, I've copied a different scripts folder to every index.


This way I can manage which scripts with what files I want to use, are ran for each image.
To save time, you can integrate a bunch of kb files, copy over the first set of scripting,
export to another image, then re-mount, copy over the second set of scripts, rename the index, and reexport it.
To do something like that you'd use a script such as:
dism /mount-wim /wimfile:c:\win80x86\sources\install.wim /index:1 /mountdir:c:\mount
dism /image:c:\mount /add-package /packagepath:e:\win8slipstream\kbfiles\x86
if not exist c:\mount\windows\setup\scripts mkdir c:\mount\windows\setup\scripts
xcopy e:\win8slipstream\OEM\x86\$oem$\$$\setup\scripts\* c:\mount\windows\setup\scripts
/cherkyi
dism /unmount-wim /mountdir:c:\mount /commit
imagex /info c:\win80x86\sources\install.wim 1 "Windows 8.0 (Core) x86" "Windows 8.0 (Core)x86"
imagex /compress maximum /export c:\win80x86\sources\install.wim 1 c:\temp\install.wim
dism /mount-wim /wimfile:c:\win80x86\sources\install.wim /index:1 /mountdir:c:\mount
dism /image:c:\mount /add-package /packagepath:e:\win8slipstream\kbfiles\x86
if not exist c:\mount\windows\setup\scripts mkdir c:\mount\windows\setup\scripts
xcopy e:\win8slipstream\OEM\PAx86\$oem$\$$\setup\scripts\* c:\mount\windows\setup\scripts
/cherkyi
dism /unmount-wim /mountdir:c:\mount /commit
imagex /info c:\win80x86\sources\install.wim 1 "Windows 8.0 (Core) Pre-Activated x86" "Windows
8.0 (Core) Pre-Activated x86"
imagex /compress maximum /export c:\win80x86\sources\install.wim 1 c:\temp\install.wim
Then at the end of your script you use a move command to overwrite your old install.wim before iso'ing
everything up.
It's simple and looks like this:
move /y c:\temp\install.wim c:\win80x86\sources\

So with those few tricks you could make a baseline image with 9 unactivated indexes and 9 activated
indexes having exactly the same kb files integrated for all, but having different scripting for the different
types. It's more difficult to deal with mounting each image, copying over different files, and then reexporting to a temp image. Some people can't really wrap their minds around it and can't seem to do
itcorrectly, so I saved it for the last topic, though I don't feel like it's very hard.
As to the contents of the pre-activated index, that's a whole 'nother story. It's fairly easy for Windows
Loader, but since that no longer works for KMS stuff, you either need a silent activator, or a series of
commands in a script form.
So with those few tricks you could make a baseline image with 9 unactivated indexes and 9 activated
indexes having exactly the same kb files integrated for all, but having different scripting for the different
types. It's more difficult to deal with mounting each image, copying over different files, and then reexporting to a temp image.
As to the contents of the pre-activated index, that's another story.
It's fairly easy for Windows Loader, but since that no longer works for KMS stuff, you either need a silent
activator, or a series of commands in a script form.
Here one example of $OEM$ folder para descargar.
http://www.linkbucks.com/Wan0

5) Win8.x install.esd compression (Saving Space)


In Windows 8.0 and higher, you can use an install.esd file instead of install.wim file. Here I will cover a
few topics. Firstly, you need to know what it is. Secondly, you need to know how to use it. And lastly you
need to know how to go about creating the file without causing errors.
Install.esd recovery compressed files are MUCH smaller than install.wim max compressed files.
Depending on the data it can range from half as large to about 80% as large or so. They're typically
worth the use; but I would recommend keeping a backup of your install.wim file; in case you need to
modify some things and re-create the install.esd file.
Install.esd files are versions of install.wim files that simply can use a different compression method for
the indexes. A typical install.wim file is broken up into 3 sections: Top xml information, middle index
binary data, and bottom xml information. In an install.esd file, the same basic format is used, except the
middle index binary data is compressed in a different method. We believe that Microsoft uses a highly
efficient hashing method, combined with LZMS compression to store different chunks of data in an
efficient manner.
For install.wim or install.esd with max compression, it simply sequentially compresses the data much as
you would if you compressed a large folder with 7zip or winrar. For install.esd recovery compression, it's
much different. They catalog the chunks of data and hash them to determine the uniqueness. Where
the sequential method compresses files that match, the recovery compression matches up chunks of
files. It's far more efficient, since MS loves to add small changes to files when integrating or building new
versions. For instance, perhaps they make a large data file, but simply change the signed portion and a
few minor code tweaks. Well the max compression method would see this as an entirely different file
and skip trying to match it with a previous version. The recovery compressed esd file would break it up
into chunks and simply copy the non-matching parts to the compilation and add placeholders for the

parts that do match.


Note that install.esd recovery compressed images are not modifiable. You can apply them and create
them, but you cannot edit them after the fact. You can add other indexes to an already existing
install.esd file though.
install.esd files are very straightforward to use. Microsoft has been excellent in allowing them to be used
in both the setup discs and the recovery partition. If you want to learn more, you can check their page
about shrinking the push-button reset images. This would be a good way to make better use of smaller,
but faster, solid state drives:
http://technet.microsoft.com/en-us/library/dn293447.aspx
For setup discs, you simply copy the install.esd file into the sources\ directory and remove the
install.wim file if it exists.
So how do you create these more compressed install.esd files?
Well, there's really only one way to actually create the file, but the way you do it is important. I'm not
talking about Microsoft's encrypted downloaded esd files. Those, we cannot create; yet. I'm talking
about the versions that are already decrypted, typically named install.esd rather than something like
WindowsBlue-ProESDwithApps-32bit-English-X1897212.esd which is the encrypted variant.
Do extract your indexes to a separate temporary install.wim before creating the esd file. Don't try to
create the esd file on the fly during a long script where you are constantly modifying the install.wim.
For example, DO:
dism /mount-wim /wimfile:c:\win81x86\sources\install.wim /index:1 /mountdir:c:\mount
dism /image:c:\mount /add-package /packagepath:c:\x86kbfiles
dism /image:c:\mount /set-productkey:XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
dism /unmount-wim /mountdir:c:\mount /commit
imagex /info c:\win81x86\sources\install.wim 1 "Modified 8.1 index 1" "Modified 8.1 index 1"
dism /export-image /sourceimagefile:c:\win81x86\sources\install.wim /sourceindex:1
/destinationimagefile:c:\temp\install.wim /checkintegrity /compress:max
dism /mount-wim /wimfile:c:\win81x86\sources\install.wim /index:2 /mountdir:c:\mount
dism /image:c:\mount /add-package /packagepath:c:\x86kbfiles
dism /image:c:\mount /set-productkey:XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
dism /unmount-wim /mountdir:c:\mount /commit
imagex /info c:\win81x86\sources\install.wim 2 "Modified 8.1 index 2" "Modified 8.1 index 2"
dism /export-image /sourceimagefile:c:\win81x86\sources\install.wim /sourceindex:2
/destinationimagefile:c:\temp\install.wim /checkintegrity /compress:max
dism /export-image /sourceimagefile:c:\temp\install.wim /sourceindex:1
/destinationimagefile:c:\temp\install.esd /checkintegrity /compress:recovery
dism /export-image /sourceimagefile:c:\temp\install.wim /sourceindex:2
/destinationimagefile:c:\temp\install.esd /checkintegrity /compress:recovery
move /y c:\temp\install.esd c:\win81x86\sources\
del /q/s c:\win81x86\sources\install.wim
DO NOT DO THIS METHOD:
dism /mount-wim /wimfile:c:\win81x86\sources\install.wim /index:1 /mountdir:c:\mount
dism /image:c:\mount /add-package /packagepath:c:\x86kbfiles

dism /image:c:\mount /set-productkey:XXXXX-XXXXX-XXXXX-XXXXX-XXXXX


dism /unmount-wim /mountdir:c:\mount /commit
imagex /info c:\win81x86\sources\install.wim 1 "Modified 8.1 index 1" "Modified 8.1 index 1"
dism /export-image /sourceimagefile:c:\win81x86\sources\install.wim /sourceindex:1
/destinationimagefile:c:\win81x86\install.esd /checkintegrity /compress:recovery
dism /mount-wim /wimfile:c:\win81x86\sources\install.wim /index:2 /mountdir:c:\mount
dism /image:c:\mount /add-package /packagepath:c:\x86kbfiles
dism /image:c:\mount /set-productkey:XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
dism /unmount-wim /mountdir:c:\mount /commit
imagex /info c:\win81x86\sources\install.wim 2 "Modified 8.1 index 2" "Modified 8.1 index 2"
dism /export-image /sourceimagefile:c:\win81x86\sources\install.wim /sourceindex:2
/destinationimagefile:c:\win81x86\install.esd /checkintegrity /compress:recovery
del /q/s c:\win81x86\sources\install.wim
You may ask, why? They look the same. Well they're not.
This poor method will leave the install.esd index1 in memory for a long time while integrating and tends
to create install problems. The user, when trying to install an index that has not be exported to a
temporary wim file before exporting to install.esd recovery compression will often error out
between 85 and 97 percent. It will give some sort of invalid data error messages and generally just cause
a lot of headaches. I've used these methods for quite a while now and I will insist that you trust me on
this. If you really want to test your luck using the non-recommended method, that's on you.
You may notice the /checkintegrity flag I use in my examples. These are more of a precaution than an
actual control. You can still have image errors with this enabled, and you can potentially block perfectly
good indexes from being added to your install.wim and/or install.esd file.
So why use it you ask? It just helps keep the quality higher. If you run a long script where every index has
it's integrity checked, and none of the indexes are missing during install; it's reasonable to assume that
the entire image is fine. I would still recommend installing the last image and doing an
"sfc /scannow" check for good measure before handing off your work to others.

zorro48