Windows AIO Installers with x64 System Repair [SOLVED] (I think)

Discussion in 'Windows 7' started by gregsnell, Nov 16, 2014.

  1. gregsnell

    gregsnell MDL Novice

    Aug 5, 2014
    6
    0
    0
    #1 gregsnell, Nov 16, 2014
    Last edited: Nov 17, 2014
    OK a while ago I worked out how to create a dedicated system repair disc directly from the original Windows media (so far seems to work for Vista, 7 & 8). The key to this is that the files used in the recovery environment are those in image 2 in the boot media's boot.wim file. After exporting this to a seperate WIM file we can then mount the image and add a simple winpeshl.ini file to automatically launch the recovery environment. Once the changes are then commited back to the new WIM file, that's basically it. This appears to be how Windows itself creates recovery discs. The upshot of this is that the new WIM file can then be added to a copy of another (x86 or AIO) boot media and with an entry in the BCD store you can to boot to either "Windows Setup & x86 System Repair" or "x64 System Repair".

    Like I said I haven't tested this much and probably wouldn't know how to figure out what is wrong if it doesn't work but it does seem to work and maybe this can get the ball rolling.

    It also allows the possibility of creating a universal system repair disc for ALL versions & architectures of Windows.

    The process I used to create these is as follows (you will need GImageX by AutoIT)...

    1) Create the following folders:
    C:\WinRecovery
    C:\WinRecovery\boot
    C:\WinRecovery\mount
    C:\WinRecovery\sources

    2) Insert the disc into your DVD drive (or mount the ISO) and copy the following files across to their respective folders in your WinRecovery folder:
    bootmgr​
    boot\bcd​
    boot\boot.sdi
    boot\bootfix.bin
    boot\memtest.exe​

    3) Run GImageX.exe, select the export tab and set the settings as follows:
    Source WIM​
    Source = D:\sources\boot.wim (assuming your D: is your DVD drive)​
    Image = 2​
    Destination WIM​
    Destination = C:\WinRecovery\sources\boot.wim
    Compression = As desired (Maximum recommended)​
    Name = Microsoft Windows Recovery Environment (x##) (where ## is either 86 or 64 depending on the target architecture)​
    Boot = CHECKED​
    Options​
    Check = UNCHECKED​

    4) Click the export button and once completed close the "Imaging Operation In Progress" window

    5) Select the change tab and set the settings as follows:
    WIM​
    Source = C:\WinRecovery\sources\boot.wim
    Image = 1
    New Information​
    Name = Microsoft Windows Recovery Environment (x##)​
    Description = Microsoft Windows Recovery Environment (x##)​
    SKU = BLANK​
    Display Name = Microsoft Windows Recovery Environment (x##)​
    Display Desc. = Microsoft Windows Recovery Environment (x##)​
    Options​
    Boot = CHECKED​
    Check = UNCHECKED​

    6) Click the change button and once completed close the "Imaging Operation In Progress" window

    You now have a basic CD/DVD layout with an extra folder that will be removed later (mount). Now we need to modify the image held in boot.wim:

    7) Select the mount tab and set the settings as follows:
    Mount​
    Mount Point = C:\WinRecovery\mount
    Source = C:\WinRecovery\sources\boot.wim
    Image = 1
    Read and Write = CHECKED​
    Unmount = LEAVE​

    8) Click the mount button and once completed close the "Imaging Operation In Progress" window

    9) Minimise GImageX.exe and open C:\WinRecovery\mount\Windows\System32 in Windows Explorer

    10) Create a new text document and rename the new file "winpeshl.ini" (make sure you remove the .txt from the end)

    11) Open the winpeshl.ini file in Notepad and enter the following 2 lines:
    [LaunchApp]
    AppPath=X:\sources\recovery\recenv.exe​

    12) Save the file then close Notepad and return to GImageX.exe

    13) In the unmount section of the mount tab, select the only item in the list and ensure the commit changes checkbox is CHECKED

    14) Click the unmount button and once completed close the "Imaging Operation In Progress" window

    15) Close GImageX.exe

    16) Delete the following folder:
    C:\WinRecovery\mount

    You have now modified the boot.wim so that it will automatically launch the Recovery Environment when loaded. Once you have this you can either create an ISO image for burning (don't forget to copy the boot sector from the original media), or you can integrate it into another image for an AIO solution.

    To do this, you need to rename the boot.wim to something else (recovery.wim is my favourite) and add it to the "sources" folder of the AIO image. After this you can set about editing the BCD store and adding an entry that points to your new recovery.wim file. You should also change the menu text for the original entry that points to the original boot.wim so that it is more meaningful (I go with "Windows Setup & x86 System Repair"). When booting from the resulting media you will now have a menu to choose which WIM file you want to boot from. Instructions for doing this are in post #4 below.

    I hope this works for you as it has for me (albeit only tested as far as booting to the recovery environment as I'm not prepared to screw up my computer just to test a repair disc).
     
  2. CEW

    CEW MDL Senior Member

    Jan 21, 2011
    296
    155
    10
    Thanks Greg.

    What is the purpose of exporting image 2?

    You might find it easier to add winpeshl.ini directly into boot.wim 2\Windows\System32 with 7-zip, no need to export, or mount.
     
  3. gregsnell

    gregsnell MDL Novice

    Aug 5, 2014
    6
    0
    0
    #3 gregsnell, Nov 17, 2014
    Last edited: Nov 17, 2014
    (OP)
    It was a while ago that I did this but I've retraced my steps.

    WIM files can only contain one bootable image. In the original boot.wim the bootable image is already image #2 and acts as the installer. You could easily just rename the boot.wim from the x64 disc and add the winpeshl.ini file but I chose to export it for 3 reasons. The first is that it saves a little bit of space in the resulting installer. The second (far less important) reason, is that when windows creates a repair disc, it only contains a single image. And the third (even less important) reason, is that as we're messing around with ImageX/GImageX anyway, I thought we might as well.

    I had no idea that 7-Zip could even read WIM files, so I just tried it and whenever I try and add a file I just get the "Operation is not supported" error. :-( Have you managed to add to WIM files before with 7-Zip?

    Edit: Just looked at the 7-Zip homepage and it says it only supports unpacking of WIM files. You'd have thought it wouldn't take too much effort to be able to support adding to WIM files but I suppose the difficulty is in supporting all the extra image info and tags etc.
     
  4. gregsnell

    gregsnell MDL Novice

    Aug 5, 2014
    6
    0
    0
    #4 gregsnell, Nov 17, 2014
    Last edited: Nov 17, 2014
    (OP)
    And now to expand on editing the BCD store. To add the new menu option to the BCD store, I used Visual BCD Editor by BoYans and the steps are as follows...

    1) Run Visual BCD Editor and click "Store", then "Open Store" (VERY important as it automatically load the OS's BCD store and you don't really want to be editing that)

    2) Select the file named "bcd" (no file extension) in the "boot" folder of the AIO installer source files

    3) Right-click anywhere in the "BcdStore" tree and click "New Vista/7/VHD Loader"

    4) In the "Loaders" section of the "BcdStore" tree, select the "New Vista/7/VHD Loader"

    5) In the "Elements" tab to the right of the window, click the "New" button

    6) Set the options as follows:
    Object = OS Loader​
    Element = DetectKernelAndHal​

    7) Repeat step 5 and 6 to add two more elements entitled "WinPEMode" and "EmsEnabled"

    8) Select the "DebuggerEnabled" element and click the "Delete" button

    9) Set the following elements to these values (double-click on the element to modify it if necessary):
    ApplicationPath = \windows\system32\boot\winload.exe
    Description = x64 System Repair (or whatever you want it to show as in the boot menu)
    PreferredLocale = English (United States) (you should be able to set this to your country but I haven't tested this yet)
    SystemRoot = \windows
    DetectKernelAndHal = TRUE
    WinPEMode = TRUE
    EmsEnabled = TRUE

    10) Double-click the "ApplicationDevice" element and set the settings as follows:
    Type = RamdiskDevice
    AdditionalOptions = {7619dcc8-fafe-11d9-b411-000476eba25f}
    Drive = [boot]
    Path = \sources\recovery.wim (or whatever you renamed your system repair WIM file to)

    11) Double-click the "OSDevice" element and set the settings to the same as in step 10

    12) In the "Loaders" section of the "BcdStore" tree, select the "Windows Setup" loader

    13) Double-click the "Description" element and set it to "Windows Setup & x86 System Repair" (again, this can be set to whatever you want it to show as in the boot menu)

    14) Optionally, you can change the boot menu title and timeout by selecting the "{bootmgr}" section of the "BcdStore" tree and setting the "Description" and/or "Timeout" elements as you desire

    15) Close Visual BCD Editor (changes are automatically saved on-the-fly)

    That's it! you have now modified your BCD store to give you the option to boot into either "Windows Setup & x86 System Repair" or "x64 System Repair".

    Now go burn that DVD (or just create a bootable USB installer. That's been covered many times before so I won't cover that here).
     
  5. CEW

    CEW MDL Senior Member

    Jan 21, 2011
    296
    155
    10
    If you have 7-zip 34 version, rt click folder/file you want to add to wim.

    Select Add to Archive.

    Select .wim in dropdown.

    Browse to wimfile .

    7z.jpg
     
  6. gregsnell

    gregsnell MDL Novice

    Aug 5, 2014
    6
    0
    0
    I have 7-Zip 9.22beta x64 and if i try to add a file it tells me "Update operations are not supported for this archive".

    If you're on about unpacking the wim then adding the winpeshl.ini then repacking, then I would imagine the newly created WIM image wouldn't have the bootable flag and would therefore (maybe) be unusable.
     
  7. Carlos Detweiller

    Carlos Detweiller Emperor of Ice-Cream

    Dec 21, 2012
    6,316
    7,023
    210
    You need 9.34 alpha.
     
  8. gregsnell

    gregsnell MDL Novice

    Aug 5, 2014
    6
    0
    0
    Ahh OK. Yes I suppose that would be simpler. Like I said though I am trying to as closely match the Windows created boot discs as possible. I would be great if we could find a way to either get the setup.exe working for both x86 and x64 as well. Then we'd be able to have a completely universal install disc/USB. Currently, I just entirely remove the remove the setup.exe from the source. I reckon this would most likely require a rewrite of the setup.exe though.