Creating Windows OEM recovery DVDs with Windows AIK (part 2)

Posted on Updated on

In this post I’m going to continue creating the scripts (and manual steps) to restore the windows image file and show alternatives to the creation of the DVDs. To fully understand the process I recommend reading the part 1 of this series.


By now you should have your set of restoring DVDs and the bootable DVD that includes the tools required to continue the process.

I’m going to start explaining the manual steps to restore the image, so you can understand what’s going on, and then I’ll give you the code for the restore.cmd script that can be used to restore the system automatically.



Go and get yourself a coffee while you back-up your data, as the restoring process described here cleans the hard drive.


Create partitions

The first thing the we need to do is to clean the disk and create the partitions. To do that we will use diskpart.

The process involves creating 2 partitions. The first one is for Windows. Here I’ve used a 40GB but you can choose what you want. and the second needs to be al least 15GB to copy all the image parts, as the tool imagex doesn’t prompt for multi-disk image and we need to do this manually. I wouldn’t be too worried by now about the size of the partitions. I my case, once I had the system restored and Windows finished installing, I went to the Windows Disk Management tools and I resized the Windows partition and created some Striped partitions (RAID 0) to improve performance.

In case you need to use Windows HD encryption, you will need to create 3 partitions. 1st for the partition called “system” (this one will be the active one, and it doesn’t need a letter assigned as it’s hidden)

After booting from the boot DVD you will have a command prompt.

Type: diskpart

SELECT DISK 0                              

CREATE PARTITION PRIMARY SIZE=40000       (create a 40GB partition for Windows)
ASSIGN LETTER="C"                  

CREATE PARTITION PRIMARY                (create a second partition in the disk for the remaining)
SELECT PARTITION 2               
ASSIGN LETTER="e"                           



Copy image parts to disk

Now that we have the partitions we need to copy the image parts and the tool to restore the image to e:

In case you had the image parts in an external HD or USB Key or the second HD, you don’t need to copy the files locally. Instead you could connect your USB external HD and go to the next step (restore the image) because the system can detect the external HD when you plug it in and read the image directly from there (you only need to type the right source location)

copy d:\imagex.exe e:\

copy d:\sources\asus.swm e:\

(change to DVD 2 )

copy d:\sources\asus2.swm e:\

(change to DVD 3 )

copy d:\sources\asus3.swm e:\


Restore the image

Once we have the files in the HD e:, we need to go to e: (where we have the imagex.exe file) and apply the image to the HD c: with the next command

imagex /ref e:\asus*.swm /apply e:\asus.swm 1 c:

The command:

  • /ref e:\asus*.swm   => tells the imagex program that the file is in several parts and needs to reference all the files called e:\asus*.swm
  • /apply e:\asus.swm 1 c:  => tells the imagex program that the file to apply is called e:\asus.swm (to create that file uses the /ref files) and it needs to apply from that file the image number 1 (because the tools support several images in a single file) to the HD called C:

This process can take a while, just wait until it’s finished.


Make the HD bootable

Now that the Windows image has been restored we need to make that image bootable. To do that we need to go the the restored Windows system files and run the bcdboot command.

CD c:\Windows\System32
BCDBOOT C:\Windows



At this stage your system has already been restored and you need to reboot. Remove all your DVDs and restart the machine.

You can type wpeutil reboot to do so.

If everything went Ok, your system must be restarting and finishing the installation in the same way it did the first day that you used your computer. So finish the install, fix your partitions and uninstall all the rubbish that thy have installed by default. I also recommend to create a backup of your system once you have it the way you like it, and next time you can restore it to that state directly without having to do all these steps.


The scripts

To finish creating the fully automated restore you can use the following scripts (to continue the process in the part 1).

There are 2 txt files with the commands for diskpart to clean the HD and create partitions. The reason why is that depending on the HD partitions before restoring the system, when the restoring starts, the partitions are mounted in different drive letters. If this happens, the scripts don’t know which drive contains the tools and where to copy the image files. To solve that, what I have implemented is a 2 steps recovery. First, I check if the tools are in the expected location (it happens when the HD is clean). If the script can’t find the tools in the HD d:, then cleans the HD and restarts automatically. Next time the system boots, we know where we are and we can automate the process. There are better ways to do this, but this one works and I didn’t want to spend too long for a process that shouldn’t happen more than once or twice a year.


Diskpart clean HD (clear_partitions.txt)

SELECT DISK 0                               




Diskpart clean HD (create_partitions.txt)

SELECT DISK 0                               

ASSIGN LETTER="C"                  

SELECT PARTITION 2               
ASSIGN LETTER="e"                           





In this script I have added a bit of error checking, some CLS (clear screen) and messages to make it look a bit better and easier to use once it’s been deployed.

You can modify the script to adapt it you your convenience in case you have a different number of DVDs or you are creating images for other machines.

  1. The first section I check if the tools are where I expect. If they aren’t I clean the HD and I restart (I have explained this above).
  2. In the second section I check if the *.swm files are where I expect. If they aren’t I prompt to change the disk and try again. When you change the disk, some times it takes a couple of seconds for the system to pick it up, so be patient.
  3. After the files are copied I copy imagex to e: and start restoring
  4. Then I create the boot for the new Windows
  5. And I restart. I used the command ping to wait for 5 seconds and let the user see that it’s all good, but you can remove this step (ping -n 6 > nul  each ping take 1 second)
  6. If there was any error I jump to the end and I finish the process

@echo off
@echo. ———————————————–
@echo.            Initializing Hard Drive
@echo. ———————————————–


IF NOT EXIST d:\create_partitions.txt (
    @echo. Cleaning the HD and rebooting afterwards
    diskpart /s clear_partitions.txt

    wpeutil Reboot

@echo. Initialising the HD
diskpart /s d:\create_partitions.txt

if errorlevel 1 goto :errorPartitions

copy d:\imagex.exe e:\

@echo. ———————————————–
@echo.         Copying the images from DVD
@echo. ———————————————–


IF NOT EXIST d:\sources\asus.swm (
    @echo. File not found d:\sources\asus.swm
    @echo. Insert the DVD 1 and wait 5 secs. until DVD is loaded
    goto :retryFile1
@echo. Copying DVD 1 (d:\sources\asus.swm)
copy d:\sources\asus.swm e:\
if errorlevel 1 goto :retryFile1

@echo. Insert the DVD 2 and wait 5 secs. until DVD is loaded
IF NOT EXIST d:\sources\asus2.swm (
    @echo. File not found d:\sources\asus2.swm in DVD 2
    goto :retryFile2
@echo. Copying DVD 2 (d:\sources\asus2.swm)
copy d:\sources\asus2.swm e:\
if errorlevel 1 goto :retryFile2

@echo. Insert the DVD 3 and wait 5 secs. until DVD is loaded
IF NOT EXIST d:\sources\asus3.swm (
    @echo. File not found d:\sources\asus3.swm in DVD 3
    goto :retryFile3
@echo. Copying DVD 3 (d:\sources\asus3.swm)
copy d:\sources\asus3.swm e:\
if errorlevel 1 goto :retryFile3

@echo. ———————————————–
@echo.          Restoring image to drive C:
@echo. ———————————————–


imagex /ref e:\asus*.swm /apply e:\asus.swm 1 c:

if errorlevel 1 goto :errorRestore

@echo. ———————————————–
@echo.          Setting up boot partition
@echo. ———————————————–


CD c:\Windows\System32
BCDBOOT C:\Windows

if errorlevel 1 goto :errorBoot

@echo. ———————————————–
@echo.              Process Finished!
@echo.      The system will reboot in 5 seconds
@echo. ———————————————–

ping -n 6 > nul

wpeutil reboot

@echo. There was an error cleaning the hard disk and creating the partitions.
goto :end

@echo. There was an error restoring the image.
goto :end

@echo. There was an error creating the boot.
goto :end




At this stage you are smarter than the guys that developed the restoring system for ASUS because:

  • you understand all the recovery process (the tech support has no idea and they will tell you that you can’t be happy and that you need to take the computer for them to restore it and waste your time for few hours)
  • you are able to create a more flexible set of recovering disks (ASUS want you to be unhappy trying to restrict you how to use the computer that you have bought)
  • You no longer have a 20GB partition in your HD.

If ASUS was smarter, they would give you the original install install disk (I would have paid a bit extra to avoid all the crap that they have put in my computer and that I have uninstalled anyways). They may probably get some extra cash from the companies of the preinstalled rubbishware they put in your machine, but in a long term, they end up paying back all that money because of they need a larger number of people in support to attend complains and answering users and they have to spend extra resources as electricity to keep your computer plugged-in while restoring.

Enjoy your coffee!!

Update: I have added a new post in where I explain how to fully customise the WIM image, update it with service packs and updates and remove bundled crap to create an updated and clean image that can be safely used to bring your computer to a clean state without the pain of running all the Windows updates again. Please check my post.

24 thoughts on “Creating Windows OEM recovery DVDs with Windows AIK (part 2)

    sasa said:
    July 9, 2010 at 05:36

    Really great tutorial, I have not found better on the web ….🙂 thank you

    Michael VanDenBoom said:
    March 2, 2011 at 04:02

    I was curious..I cant get you script to work

    imagex /ref e:\asus*.swm /apply e:\asus.swm 1 c:
    I type this in exactly as you put it however, it always tells me file not found. I have Asus.swm and asus2.swm saved to the e:drive as well as imagex.exe I can’t figure this out and it is making me go nuts. Any advice? I am using the same cmd prompt from off the first disk we burned in this tutorial. Can you please help me?

      Michael VanDenBoom said:
      March 2, 2011 at 23:21

      Ok so it turned out my dvd drive was being labeled as F:. Problem solved.

    Michael Nash said:
    July 27, 2011 at 19:17

    Roberto I read your post with great interest and have a few questions for your expertise regarding my asus U35 laptop
    1 – I was able to unhide and copy all the contents of the asus recovery partition to an external HD then rehid the partition,
    I created a bootable USB with the contents of the partition. indeed it does boot up to the grey windows like background but instead of asking what language I want as happens when using F9 boot recovery it hangs and then reboots to windows
    seems like something in the boot config on the USB any thoughts?
    2 – in perusing all the files on the hidden partition I found in the asuslog folder a file called sumOS_L.txt
    this file contains a list of directories and files apparently used during recovery

    the main list is as follows
    Directory of C:\

    03/30/2010 01:21 AM ASUSLog
    09/17/2009 10:33 PM boot
    09/17/2009 10:33 PM DisableS3S4
    09/17/2009 10:33 PM efi
    09/17/2009 10:33 PM fac
    09/17/2009 10:33 PM sources
    04/13/2010 06:26 PM 19 AsToolCD.txt
    01/18/2008 06:45 AM 333,203 bootmgr
    01/22/2008 12:51 AM 390,720 imagex.exe
    04/29/2010 06:47 PM 2,534 AsFac.log
    04/29/2010 06:47 PM 47 AsConfig.ini
    5 File(s) 726,523 bytes

    Indeed all these directories exist in the recovery partion EXCEPT for fac

    the list of files within c:\FAC includes

    09/22/2010 06:45 AM 1,050,876,731 Office201064_he-HE_Win7.wim
    09/22/2010 06:45 AM 194,904,064 NERO64.PQA
    09/22/2010 06:45 AM 9,175,040 APP1364.PQA
    09/22/2010 06:45 AM 267,386,880 APP164.PQA
    09/22/2010 06:45 AM 121,032,614 ASUSDVD64_win7.wim
    09/22/2010 06:45 AM 345,337,943 TIS64_Win7.wim
    09/22/2010 06:45 AM 101,158,563 Addon64_Win7.WIM

    these look for all the world like images of office and asus’ version of win7 and addons etc
    yet even though they are listed I CANNOT find them anywhere including within the asus.wim (and asus2 and 3.wim) files
    I presume they are created during the recovery process?? but from where is the code taken???
    is there a way you can think of to find an extract these images? if you do many asus users could make “clean” recovery USB or DVD based on the asus images.

      Roberto Mencia responded:
      July 27, 2011 at 22:40

      Hi Michael,

      If you have the original partition still available, you can create the recovery DVDs directly with the tool that ASUS provides, if your partition is still recognised (maybe the easiest solution). In my case, It didn’t work and I couldn’t be bodered to go to ASUS technicians to wipe by data.

      You need to check for the files in the partition, don’t trust that txt file that you have, as the have probably left it there from their original restoring images.
      Look for any WIM file that you have OR “any other big files”, and start from there. In your explorer you may need to enable visibility on hidden/system files, just in case.
      The other option is that they renamed the file and it’s not called WIM, maybe it’s called TIM, just because the guy that setup the images was called like this, who knows🙂, they don’t seem to make a lot of sense the HW vendors now a days (that’s why you need to look for any other large files).

      What I would recommend is that you install a Virtual Machine (VirtualBox works very well and it’s free) so you can test your installs in the VM instead of your real computer. In the VM image install won’t activate work because it’s an OEM version targeting ASUS, but it’ll run through most of the process so you can validate that your steps are correct. It’ll also allow you to kill installs and restart the process without having to shutdown your computer.

      I would also recommend you to use Windows Backup to backup all your system in an external drive. This is the best tool ever. It creates an image of your current system and in case you destroy it youjust need to start with the win7 recovery disc and choose the backup file from the external usb drive and every goes back to the original state, partitions and everything.

      I don’t know if this confuses you or gives you any ideas, but I can’t help you

        Michael Nash said:
        August 2, 2011 at 07:13

        Hi Roberto
        thanks for the reply.
        interesting that you think that the text file is a “leftover”. I can tell you that every directory listed exists in the recovery partition except for c:/FAC
        regarding the recovery disks – I did use AI burner and a virtual DVD burner (no physical burner on the U35) to create 5 DVD iso images. I have these on an external HD
        when I put these on a bootable USB they did not boot…..
        also – as I noted I unhid the recovery partition, copied all of it (well now that I think about it maybe the MBR is not copied?) to an external HD and rehid the original partition.
        I then copied the entire partition to a USB that I made bootable.
        as I told you it indeed boots, to the grey windows like background just like when I press F9 for recovery
        but it freezes instead of asking what language (as happens with F9) I want and then reboots to windows
        I also have the asus and asus2 and asus3.swm files combined to one big .wim file. (and extracted to a folder using 7zip)
        But what I would really like to do is get a “clean” asus win 7 image out of all the mish mash, this way if I recover the system it will be without bloatware…. yes I know I can use any win 7 iso and the key from the PC but I consider it a “challenge” to try to extract a “clean” win 7 image out of all the asus mish mash……

    Roberto Mencia responded:
    August 2, 2011 at 23:40

    I think it’s possible to create a “clean-er” image out the WIM images (still not a clean Windows 7 image like you would get if you bought it), but it’s done in a slightly different way. It would be something like .
    1- Install your ASUS images (with the crapware)
    2- Uninstall all the unwanted crap
    3- Use Windows AIK to regenerate a new image out of the current installed system (You need to do a sysprep or something like this).
    But at this point you are better off doing a Windows backup and use the restore tools to restore it. It works way faster to recover your system. The only difference is that you already have your user created with the backup.

    I’ve done a fair bit of work to get this images done in case I decided to sell the computer to give the buyer the “brand new experience”, but at this point I’m more keen to keep the system backed up in an image with service packs and apps (the way I like my system) so in case something happens I can restore it to the current status rather than having to reinstall everything and apply all the patches and stuff.

    Anyway, if yo manage to get “clean-er” image, It would be good if you could post it in your blog to share it with everyone, as I did. It’ll also help you to remember the steps in case you forget (I wouldn’t be able to reproduce the steps if I hadn’t written the posts).

    Michael Nash said:
    August 5, 2011 at 15:55

    if i gave you the file list of the asus dvd I created from the 3 asus.swm files do you think it would be possible to figure out how to extract the images of win 7? I could also get you a list of the files on the recovery CD images.

      Roberto Mencia responded:
      August 6, 2011 at 03:19

      The Windows 7 image is an OEM version and it has been customized by ASUS. You can’t get a clean image not OEM from it (that’s why MS sell it cheap to manufacturers).So, I don’t think I’m such a good alchemist to do that. If I knew how to do that I would have done it and added a post in my blog. Even if you managed to do so, you would only be allowed to install it in the same laptop legally.

      After having created the recovery DVDs, I decided that it wasn’t worth spending more time and I started enjoying my laptop. Anyway, apart from the few extra programs that are useless that I uninstalled first day, I haven’t had the need to reinstall the system again and it all works very well (and it’s been over 1 year now).

      If I were you, after having the recovery DVDs from ASUS, I wouldn’t worry too much. However, next time you buy a laptop, don’t buy ASUS (I won’t) and try to find one that comes with the Windows DVD, but I doubt that there are many manufacturers that do that any more due to price.

    Michael Nash said:
    August 6, 2011 at 18:21

    thanks for your reply roberto
    actually i would not have minded an asus modified OEM win 7 as I would have only used it on a USB for this PC if needed.
    I do realize I could probably use any ISO of win 7 home premium with the Asus key(s) [when using license crawler it extracted 3 different keys – an OEM COA and OEM SLP and a retail key from the win 7 home premium asus installation. interestingly the retail key is the same as a home premium on a dell PC i have……]

    on the other hand – I have read on a number of posts an blogs that some asus eeePC models had an option during F9 recovery to backup the recovery partition to a USB stick. on my PC this is missing, and of course the AI burner program does not give this option either. yes I know that would give a recovery with the bloatware but at least it would give a USB recovery option which at present I have been unable to achieve bloatware or not.

    I did contact asus tech support who were about as helpful as a heat rash on a summers day.
    I am still wondering what is missing or off in the boot process of the USB I did create. essentially it has the whole recovery partition on a bootable USB and it does boot but freezes without asking what language i want to recover and then reboots.

    Sorry that you feel you arent enough of an alchemist🙂 I appreciate the chance to hear your opinions.
    and I am enjoying the PC, i just look upon “beating asus at their game” as a challenge.
    I will not buy asus in the future. I understand Dell (my other PC) is better at tech support. havenot yet tried to get a dell recovery USB yet as one of my kids uses it……

    in the end will probably tweak the system remove bloatware and then use Acronis to create a recovery image…..

      Andy Waro (@AndyWaro) said:
      November 12, 2015 at 14:47

      Hi Mickeal

      I see you wrote this comment 3 years ago and I know my chances are very small but anyway…
      I have the same issue with a bootable USB key having the copy of the recovery image etc… and booting to a grey screen that doesn’t offer any options…
      did you get a fix ? do you remember ?

        Michael Nash said:
        November 17, 2015 at 07:05

        that asus computer is long gone so i never really pursued further…..

    dimirtis said:
    May 29, 2012 at 19:33

    I followed your instructions but when I boot from DVD1, it gets to a screen, a command prompt window opens, diskpart starts and then my computer reboots…

    What’s going on?

      Roberto Mencia responded:
      May 29, 2012 at 22:12

      After rebooting you need to restart with the recovery again (first step cleans up the HD to start with a well known state. I recommend reading the section “The scripts” that explains the 2 steps, the clean-up(step 0) and the restore (step1)

        teutonius said:
        July 23, 2012 at 19:22

        I have the same problem. The system reboots again and again in this step:
        “IF NOT EXIST d:\create_partitions.txt (
        @echo. Cleaning the HD and rebooting afterwards
        diskpart /s clear_partitions.txt

        wpeutil Reboot
        ) ”

        This occurs during the execution of “starnet.cmd” in “X:\windows\system32\cmd.exe”.
        Maybe I’m not using the correct partitions for my ASUS A55VD.
        Is it possible that I have to change some lines in the standard script?

        Thank you very much for this great article.

        Roberto Mencia responded:
        July 23, 2012 at 21:38

        Most likely you have a different set of drives and when you boot, it doesn’t boot mounting the d drive as the one that has the script.
        What you can do is press CTRL+C on start to stop the script and avoid rebooting.
        Once you have the command line, you can follow step by step the script (manually) but using the right drives.

        If the “diskpart /s clear_partitions.txt” command was executed correctly, you will have cleared the disk already and you should continue with the next step “diskpart /s d:\create_partitions.txt” in where d: is the drive that contains the new disk partitions.

        Other thing you can do, is find the right location in where your system has been mounted and update the scripts to reflect your specific system settings and create a new set of disks for the next time to be automated.

        Mailen said:
        May 7, 2015 at 16:03

        Hello, You must copy “create_partitions.txt” file to the root of dvd1.iso. Then will be worked fine. In these scrips the D:\ is the DVD-ROM.

    Steve Soo said:
    January 4, 2013 at 16:16

    Thank you Robert for this article.
    You’re a life saver!!
    I found it really well documented and easy to follow.

    I used your scripts to build some Recovery disks for a HP 6910p laptop with Windows XP.

    I had to make a couple of changes to your restore.cmd script.
    1. Renamed the ASUS.swm to dvd.swm ( to match my split image files)
    2. I removed “Insert/Copy from DVD 3” section ( As I didn’t need it, but very useful if I will in the future)
    3. I removed the “Setting up Boot Partition” ( Windows XP does not require it)

    I also noticed that I had to copy the “create_partitions.txt” file to the DVD1 root folder ( eg. d:\ASUS\DVD1\ location )
    Otherwise when the restore.cmd runs, it will loop “Cleaning the HD and rebooting afterwards”, since d:\create_partitions.txt will never exist.
    It only exists on x:\windows\system32 on DVD1 (per your instructions), but never referenced there.

    After running the recovery disks, creating a recovery partition “e:\” for the SWM files and restoring the OS.
    Is there anyway to run the recovery directly off the recovery partition “E:\” without needing the recovery disks?

    Keep up the good work!!

    Denise said:
    February 22, 2015 at 18:35

    This is very useful when neither “AI Recovery” nor “Asus Preload wizard” work.

    I was moving Windows to a new harddisk, so I loaded Windows recovery console from the old hdd, while the new one was connected via USB adapter.
    New partition has been created from Linux and I used imagex and bcdboot as described here (had to find a 64-bit imagex.exe since the one located on recovery partition didn’t work).

    Everything worked as expected, thank you!

    M. G. said:
    May 26, 2015 at 19:13

    Thank you VERY much for this information!!! This helped me more than I could have even imagined. Much appreciated!!

    Grzegorz said:
    December 30, 2015 at 16:00

    Hi Roberto! How can I ‘burn’ this asus.swm images on a USB Key? I ask you, because my DVD drive reads only CDs😦
    I really need to reinstall the system with this 20GB partition (cause I want to use this second, small, fast system called Express Gate, which I want to replace with GoogleOS – yes, it’s possible).

      Roberto Mencia responded:
      December 31, 2015 at 02:51

      Hi, since the USB keys don’t need to be burnt you just need to copy the files there. As the files are together in the same place you don’t need to do that much work.

    loris said:
    April 3, 2016 at 14:19

    Hi and thanks for this guide.
    I have a problem,after i insert the second DVD and load for 30 seconds or something i get the blue screen with this message “PFN_LIST_CORRUPT”.
    Is there any solution?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s