Creating Window RE Using Windows AIK


We have been getting many questions on how to create Windows RE using the Windows Automated Installation Kit (AIK). So I thought I would publish the updated instructions here. The instructions listed below are accurate as of Windows Vista RTM.


 


These instructions are also included in the Windows AIK. Please note that the ReadMe file that accompanies the Windows AIK contains an important update to the instructions.


 


Note: If you install Windows RE using the Windows OPK, please continue to follow the instructions in the Windows OPK. Those instructions remain unchanged. Use these instructions only if you do not have access to the Windows OPK.


 


Step 1: Copy Windows PE from the Installation Media


The version of Windows PE that ships with the Windows AIK does not contain the components required to support Windows RE. However every Windows installation disk contains Windows RE that can be used for recovery of Windows Vista. Therefore, we will use the Windows RE from the Windows installation media.



  1. On your technician computer, click Start, point to All Programs, then Windows AIK, and then click Windows PE Tools Command Prompt.
    The menu shortcut opens a command prompt window and automatically sets environment variables to point to all the necessary tools.
  2. Create a directory for the Windows PE image and a mount point

            mkdir c:\winre_image

            mkdir c:\winre_mount


  1. Copy the Windows PE image from the installation media using ImageX

            imagex.exe /export /boot e:\sources\boot.wim 2 c:\winre_image\winre.wim “Windows Recovery Environment”


  1. Mount the image using ImageX

            imagex /mountrw c:\winre_image\winre.wim 1 c:\winre_mount

Step 2: Add Windows RE shell script

The Windows PE we copied in step 1, does not launch Windows RE automatically. In this step, we will create a script called winpeshl.ini that will launch the Windows RE shell at startup.


  1. By using a text editor, create a file called winpeshl.ini that contains the following text:


    [LaunchApp]

    AppPath=x:\sources\recovery\recenv.exe



  1. Copy this file to \Windows\System32 directory in your mounted Windows RE directory. For example,

              copy winpeshl.ini c:\winre_mount\Windows\System32


Step 3: Add mass-storage drivers (optional)

If necessary, you can include third-party drivers (.inf) in your Windows RE image by using the peimg.exe /inf command. For example,

    peimg.exe /inf=<path> C:\winre_x86\mount\Windows

        Where <path> is the location of the. inf file.


Step 4: Add custom tools to Windows RE (optional)

You can customize Windows RE shell by creating an .xml file called WinREConfig.xml. WinREConfig.xml enables you to define custom support and diagnostic tools within Windows RE. This step is optional. For more information, refer to the Windows RE documentation in the Windows AIK.


Step 5: Save changes to the image

Unmount the image by using ImageX. For example,


    imagex.exe /unmount /commit c:\winre_mount

 


That’s it! The WinRE.wim file is now ready to be deployed on the harddisk or a WDS server. Let us know if these updated instructions do not work for you.


-Parveen


Comments (39)

  1. wosully says:

    Number 3 will not function for me at all: I have the AIK installed and Vista disk:

      3. Copy the Windows PE image from the installation media using ImageX

               imagex.exe /export /boot e:sourcesboot.wim 2 c:winre_imagewinre.wim “Windows Recovery Environment”

  2. WinRE says:

    What error do you get from imagex?

  3. wosully says:

    It states a syntax error, and shows me the imagex switches.  Do you think I am doing something incorrect here?  Running imagex from the elevated command prompt, Windows PE.

    Great articles, by the way!

  4. WinRE says:

    Seems to work fine for me. May be check the following:

    1. Double check the arguments.

    2. Make sure that you have write permission to the folder where you are copying the image.

    3. Also check that you are using the correct boot.wim. You can run "imagex /info boot.wim" to make sure that it has two images in it.

  5. wosully says:

    OK, I got it.  I just copied it from the DVD manually, then everything went well.  

    Thanks!

  6. I have been getting a lot of questions about installing WinRE on the hard disk. This is good news for

  7. philippk says:

    I got the same problem as wosully.

    I changed the syntax to

    imagex.exe /export /boot e:sourcesboot.wim 2 c:winre_imagewinre.wim “WinRE”

    and now it works.

    Great job, especially the "install WinRE on the hard disk" article!

  8. James Ihde says:

    First off, I would like to say this is a great site. However, could you dive into more detail with the WinREConfig.xml file. I am unable to get it to work properly. I created the tools folder under the working directory where RecEnv.exe is and added teh WinREConfig.xml file there as well. I modified the contents for the application I want to launch, but it does not show up on the System Recovery Options list. I just get the normal choices. I can launch my utilities through the command prompt, but I would rather be able to launch the front end through the System Recovery Options list.

    Thank you for your time!

    James

  9. WinRE says:

    Can you share your winreconfig.xml file? It should have worked fine. The following works for us:

    <Recovery>

    <RecoveryTools>

     <RelativeFilePath>FabDiag.exe</RelativeFilePath>

    </RecoveryTools>

    </Recovery>

    Please note that the RelativeFilePath is relative to the x:sourcesrecoverytools directory, and the WinREConfig.xml file should be placed under the x:sourcesrecoverytools directory as well.

  10. James Ihde says:

    Here is how my winreconfig.xml file is laid out:

    <Recovery>

    <RecoveryTools>

    <RelativeFilePath>nu2menu.exe</RelativeFilePath>

    </RecoveryTools>

    </Recovery>

    The winreconfig.xml file is in the tools folder which is under the recovery folder. The nu2menu.exe is in teh root of the tools folder.

    From my understanding it is supposed to add this to the menu that pop’s up correct? If not, what is the use of adding this file?

  11. James Ihde says:

    Well, tried it again and it works now. I went ahead and moved everything into the root directory instead of it being in a folder underneath tools. However, I did have the RelativeFilePath set to Nu2menunu2menu.exe. Also, I made sure both the tools directory and the winreconfig.xml file were lowercase. I am doubtfull that made any differences. Anyways, it is working now. Thank you for you help!

    James

  12. Un article qui pourra être intéressant pour ceux qui parmi vous, cherchent à récupérer WinRE qui n’est

  13. mccay_a says:

    I managed to run through the step as outlined and everything went as expected, however when i try to access the "Repair My Coputer" option. The files will seminly load, the windows screen appears, and the computer restarts.

    Any ideas. Could it be the hard drive i have it on, or missiong files. Do SATA drives require a driver to be inluded?

  14. WinRE says:

    Hi, What’s in your winpeshl.ini file? Is it in the right place?

    Thanks,

    -Parveen

  15. purejamie says:

    Hi there,

    I am a big fan of WinRE, however, I have a quick question:

    Is it possible to edit the text and/or icon of the custom recovery tool specified between the <RecoveryTools> tags – I would like to launch a HTA here if possible but would also like it to look nice on the menu!

    Also, being cheeky, could you tell me what the WinRE front end was written in please?

    Many Thanks, keep up the good work! cheers, Jamie.

  16. Herman says:

    Hello,

    I had no problems creating the WinREConfig.xml

    and the option is working fine.

    However, the text of my custom tools on the Recovery menu is set to "Unknown".

    Is there anybody who managed to give his custom recovery tool

  17. Herman says:

    (sorry, I accidentally hit ENTER)

    Is there anybody who managed to give his Custom Recovery Tool a more decent name

    in the Recovery menu ?

    Or am I the only one who sees "Unknown" as

    description of the tool ?

    Please let me know what you see in your case.

    It is urgent for me.

    Thank you in advance !

  18. WinRE says:

    Hi Herman,

    The tool name is taken from the version resource of the tool. WinRE uses the GetFileVersionInfo() API to extract this information: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/resources/versioninformation/versioninformationreference/versioninformationfunctions/getfileversioninfo.asp

    So embed the name of tool in the ProductName field and embed the description of the tool in the FileDescription field of the version resource of your binary.

  19. Herman says:

    Dear sir,

    Now I understand why I had no meaningful name

    as menu option.

    My custom recovery tool was in fact a .CMD file, (a .bat file) containing commands and not a compiled program.

    This is a great Blog, and the concept of WINPE is indeed a major progress for people like me who wants to have a recovery/install environment from a removable device with access to the NTFS file system.

    But there is so little information to find what kind of programs, tools we can run under it. I’ve programs in VB6 and .net 2.0 (console and Windows forms).

    I’ve looked everywhere to find more information about the limitations of WINPE 2.0 and WINRE 2.0.  

    Okay, I can run Notepad but that’s almost the only GUI application. What about a GUI filemanager ?  Will VB6 programs run, and what are the limitations. I already know I can forget .net framework.

    I understand also why Microsoft wants this WINPE/WINRE to be limited, but what kind of GUI applications can run under it ?

    Or do I have to forget my GUI dreams, and focus on cscript.exe and wscript.exe to run scripts ?

    I know I’m asking a lot here, but this seems to be the right place to get answers.

    Kind Regards,

  20. WinRE says:

    Hi Herman,

    WinRE supports base Win32 API. So any GUI applications that only use native Win32 should work fine. Notepad, Startup Repair, Complete PC Restore are all examples of such applications. Winforms are not supported.

    So yes, using cscript- and wscript- based scripting is a good option for this limited environment.

    Thanks,

    -Parveen

  21. Herman says:

    I noticed today (April, 2) that Microsoft

    released a documentation update for the WAIK, which can

    be downloaded from :

    http://www.microsoft.com/downloads/details.aspx?FamilyID=993c567d-f12c-4676-917f-05d9de73ada4&DisplayLang=en

    However, the instructions on how to create WinRE (from the WinPE.chm file) still don’t mention that the WINRE isn’t included in the WAIK, and that it must be extracted from the Vista DVD :

    imagex.exe /export /boot e:sourcesboot.wim 2 c:winre_imagewinre.wim “Windows Recovery Environment”

    I don’t understand that this essential item wasn’t corrected.

  22. WinRE says:

    Hi Herman,

    You can find the latest Windows AIK documentation with an updated Windows RE walkthrough on Microsoft TechNet at:

    http://technet2.microsoft.com/WindowsVista/f/?en/library/61e08b15-82d8-46bd-a5f1-7947193e6ed81033.mspx

    The content on Microsoft TechNet is more recent than the packaged documentation update for Windows AIK on Download Center.

    Thanks,

    Desmond

  23. Herman says:

    Thank you Desmond. I saw the updated content on Microsoft Technet a few days ago. That’s why I didn’t understand they released a documentation update without the right installation instructions.

    Best Regards,

  24. Deploying BDD is a big project. One of the first elements, and a huge time saver, is installing WDS.

  25. mattdunn says:

    Hi,

    I have tried using the instructions in Step 3 to install network drivers but it does not seem to work. The peimg.exe /inf command executes successfully but when I boot into WinRE, there is no network connectivity.

    I have successfully installed the exact same drivers on WinPE by following the instructions provided by Microsoft and it works.

    Is it possible to have WinRE access a network? Am I missing a step?

    Thanks,

    Matt

  26. abucci says:

    Hi there,

    I am trying to create a customized version of Windows RE and I was wondering a few things.

    1) Just like the person above I was wondering if it is possible to add network connectivity to WinRE. If so how?

    2) Is it possible to add more than one custom recovery tool to WinRE? I’ve been trying to play around with the .XML file with no success.

    3) Is there any difference when creating WinRe with WAIK versus WOPK? Is WOPK more flexible on what tools/options you can add to WinRE?

    Thanks,

    Anthony

  27. coolice says:

    Hi !

    – I had read your article in detail, it is a great masterpiece which I was looking for a very long time.

    – I could reproduce and creat a WinRe, just as you said.

    But I ran into a problem where I would like ot ask your help as I tried evertyhing I could.

    – When WinRe starts it is asking for the default keyboard, than you have push the Next button once more as you system search for Windows Installation. How can I bybass these dialogs ? My target is to jump directly to Complete PC Restore. I am sure it is possible, but I dont know how.

    Could you help me please with step by step help please ?

    Many thank you for yoru time and effort,

    Andrew

  28. Data1701 says:

    No Answers on the blog anymore ?

    I’m searching for a way to design a WIN RE environment with network access (RDP e.g.) WIN RE in not more or less than PE 2.0, so why not.

    Regards

    Data1701

  29. pmeinl says:

    1.

    Using Vista x64 SP1

    imagex.exe /export … 2 …

    did not work for me. I got a syntax error, and showing the imagex switches.

    imagex.exe /info shows PE being image index 1

    Using image 1 the extract worked.

    When starting repair usind F8 I got the error:

    "Windows PE cannot start because the actual SYSTEMROOT directory (X:Windows) is different from the configured one (X:$Windows.~BTWindows). This can be configured with peimg /targetpath…"

    I solved this using:

    peimg /targetpath=x: c:winre_mount

    Now it works

  30. Teqonix says:

    Hey everybody, I’m not sure if anyone else found this out or not – but I found a way to get WinRE working with network connection.

    You still need to install the network drivers on the image so WinRE can see your NIC(s), but as some have noted on here, that’s not enough to get it to work.

    It’s really simple, actually. WinPE uses a script when it starts which initializes Plug and Play devices + Network connectivity. That script is located in <WinPE mount directoryWindowsSystem32startnet.cmd

    Inside this script is the all-too-familiar wpeinit command. Run that, and you have network connectivity in WinRE, now.

    This solution works for temporary network connectivity, but it you want full network connectivity from the start of your WinRE session, then what I did is modify the WindowsSystem32Winpeshl.ini file and changed it from starting RecEnv.exe (The WinRE Recovery GUI) to starting startnet.cmd. Of course, the way Winpeshl.ini seems to work is that when the application it starts is closed, the system reboots. So, add a line to startnet.cmd which calls RecEnv.exe, and WinRE will start with network connectivity and will behave like normal from then on until RecEnv.exe is closed, which returns control to startnet.cmd, which finishes, and reboots the computer. All just like normal!

    I had some security concerns with launching startnet.cmd at first because it might give unauthorized access to a user that starts WinRE on a client machine via the command prompt that pops up, but the call function seems to lock out the command prompt window until control is returned to it. So, I’m pretty sure that it’s still secure to deploy on client systems if you intend to do that like I do.

    Anywho, hope this helps. This information seems to be a little difficult to find.

  31. Navneet12 says:

    Plz help. When I type imagex.exe in command prompt it says batch unrecognised. Plz tell if I have to download anything or what to do. I am very much perplexed. Do I have to download the AIK KIT.

  32. Navneet12 says:

    Plz help. When I type imagex.exe in command prompt it says batch unrecognised file type . Plz tell if I have to download anything or what to do. I am very much perplexed. Do I have to download the AIK KIT.

  33. ve3ofa says:

    Yes you need to download and install the WAIK

  34. Which images file did I get says:

    I tried the IMAGEX /EXPORT command but it said there was no image #2, so I tried to grab image #1 and got it, but now I'm not sure if I have a Vista directory structure or an RE one. This was from the BOOT.WIM file on an HP Pavilion recovery DVD (they don't provide Vista media so I can't repair my Vista with their disc, only reformat and restore to factory config)

  35. Jeff says:

    Works very nice 🙂

    Is there any option to add a password in it? So that end users cannot "accidentaly" boot from this image?

  36. John says:

    I'm using the Windows AIK in Windows 7. Whenever I try to mount the Winre.wim in the folder c:winre_mount I get the message: "The current logged on user does not have administrative privileges." How can I solve this?

    Thanks for the article.

  37. Andrew says:

    I am using the WAIK 3 which is based from Windows 7 however peimg.exe has been replaced with DISM.exe. the switches are not the same.

    Can somebody help me?

    Using:

    Windows Server 2008

    WIAK 3

    Windows 8 Consumer Preview DVD (for the boot.wim)

  38. Yosef Blass says:

    Andrew, I apologize that I am responding so late to your inquiry however I wrote a package that contains a pre-configured WIM which includes WinRE, DaRT and Macrium Reflect Free. I have provided all the files and source code for my project free on my blog which can be found here blassdeploymentsolutions.blogspot.com

  39. Pitbullramos23@gmail.com says:

    Minipewinpe.is_ could not be loded code is 18