Recovery Project with Boot Mode Support

Discussion in 'Scripting' started by Chibi ANUBIS, Jun 29, 2016.

  1. Chibi ANUBIS

    Chibi ANUBIS MDL Chibi Developer

    Apr 28, 2014
    1,002
    663
    60
    #1 Chibi ANUBIS, Jun 29, 2016
    Last edited: Jun 3, 2020
    HELLO !
    Is my automatic setup for the Recovery Project by AnarethoS for Windows 10, is now possible to use two AutoUnattend xml files (MBR and EFI) for create a recovery partition.

    Indeed it is an "smart" script that identifies whether it should start the AutoUnattend files for MBR or EFI, I'll explain here, I used the folder "Windows 10 Recovery".
    Work also for Windows 7, 8, 8.1 with the pach boot.wim but use the recovery software used by the system.

    SOMMARY ! POST NUMBER
    Download the PreConfig pack for Windows 7-8-8.1-10
    Detection of BIOS Mode
    Demonstration of my Recovery Project for Windows 10
    Prepare Windows 10 ISO with my Recovery Project


    EXPLICATION !
    1) PATCH THE BOOT.WIM


    Then you create winpeshl.ini and install.cmd

    winpeshl.ini
    Code:
    [LaunchApps]
    %SYSTEMDRIVE%\windows\system32\install.cmd
    
    install.cmd
    Code:
    @echo off
    SetLocal EnableDelayedExpansion
    
    FOR %%i IN (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST %%i:\efi.xml SET install=%%i:
    
    :Lastly do the UEFI detection
    :Check whether user has booted with UEFI or BIOS and set UEFI=1 if UEFI
    wpeutil UpdateBootInfo
    for /f "tokens=2* delims=     " %%A in ('reg query HKLM\System\CurrentControlSet\Control /v PEFirmwareType') DO SET Firmware=%%B
    :: Note: delims is a TAB followed by a space.
    if !Firmware!==0x1 set UEFI=0
    if !Firmware!==0x2 set UEFI=1
    
    if !UEFI! EQU 1 (
    %install%\setup.exe /unattend:%install%\efi.xml /m:%install%\recovery\efi
    ) ELSE (
    %install%\setup.exe /unattend:%install%\mbr.xml /m:%install%\recovery\mbr
    )
    exit
    
    (In this script I search "efi.xml" on DVD root to assign the correct drive letter in the script)

    winpeshl.ini and install.cmd must be integrated into the boot.wim index 2 with dism in "Windows\System32" for install.cmd be executed since the beginning of the installation.
    Code:
    Dism /mount-wim /wimfile:C:\wim\boot.wim /index:2 /mountdir:C:\mount
    
    Copy the install.cmd and the winpeshl.ini in "C:\mount\Windows\System32", rewrite winpeshl.ini.
    Code:
    Dism /unmount-wim /mountdir:C:\mount /commit
    
    2) PREPARE THE ISO

    At the root of the ISO I put the XML files that I renamed MBR and EFI. In the Recovery folder I create two folders: MBR and EFI. And I create inside a folder "$1" for Windows to copy the root of the system partition the recovery folder of AnarethoS project so it gives this: "$1\Recovery", the OOBE.cmd must give the attribut for the Recovery folder in system partition, that I already prepared for the recovery, that is to say to put the files in the folder "Settings" in "OEM" and copy "ScanState".

    OOBE.cmd
    Code:
    ATTRIB -S -R -H C:\Recovery
    ATTRIB -S -R -H C:\Recovery /S
    icacls C:\Recovery /reset /T /C
    icacls C:\Recovery /inheritance:r /grant:r SYSTEM:(OI)(CI)(F) /grant:r *S-1-5-32-544:(OI)(CI)(F) /grant:r *S-1-5-32-545:(OI)(CI)(RX) /C
    ATTRIB +S +H C:\Recovery
    RMDIR /S /Q "%WINDIR%\Setup\Scripts"
    exit
    
    I create also a cmd that I put in root for my iso for run the Recovery when I finished to install driver and software. Because the Recovery folder was hidden.

    sysprep.cmd
    Code:
    start "Sysprep" "C:\Recovery\OEM\Sysprep.cmd"
    exit
    
    Architecture of the ISO :
    Code:
    ISO\recovery\mbr\$1\Recovery
    ISO\recovery\efi\$1\Recovery
    ISO\recovery\mbr\$$\Setup\Script\OOBE.cmd
    ISO\recovery\efi\$$\Setup\Script\OOBE.cmd
    ISO\mbr.xml
    ISO\efi.xml
    ISO\sysprep.cmd
    
    Now you can just install software and driver and then launch "Sysprep.cmd" and everything is ready.

    I made this project to save on DVD since I was four with two more the recovery architecture or two if I make an AIO, now one is enough, and even more by USB it works it's really cool !

    I hope I was clear enough if need does not hesitate to come back to ask me anything at all.

    DON'T FORGET LIKE THIS POST ! :clap:

    Voilà ! :)
    [​IMG]
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. wk-952

    wk-952 MDL Member

    Sep 2, 2012
    116
    286
    10
    #2 wk-952, Jun 29, 2016
    Last edited by a moderator: Apr 20, 2017
    This is not a solution to your problem but something worth mentioning.
    You are using the exclamation mark to expand variables (delayed variable expansion):
    Code:
    if !Firmware!==0x1 set UEFI=0
    if !Firmware!==0x2 set UEFI=1
    if !UEFI! EQU 1 (
    
    But you don't seem to enable delayed variable expansion at the beginning of your script after the line "@echo off"
    so you're comparing the string "!UEFI!" (literally as it is like that) against the number one, which of course will always be false.

    As for your original problem, are you sure the file "MBR.xml" exists in the root directory of the setup ?
     
  3. Chibi ANUBIS

    Chibi ANUBIS MDL Chibi Developer

    Apr 28, 2014
    1,002
    663
    60
    #3 Chibi ANUBIS, Jun 29, 2016
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Thank you wk-952 :)

    My file xml exist in the root of directory but the setup not found "X:\MBR.xml not found" I test on VMware.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. Chibi ANUBIS

    Chibi ANUBIS MDL Chibi Developer

    Apr 28, 2014
    1,002
    663
    60
    #4 Chibi ANUBIS, Jun 29, 2016
    Last edited by a moderator: Apr 20, 2017
    (OP)
    I updated :
    Code:
    @echo off
    SetLocal EnableDelayedExpansion
    
    FOR %%i IN (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST %%i:\setup.exe SET Install=%%i:
    
    :Lastly do the UEFI detection
    :Check whether user has booted with UEFI or BIOS and set UEFI=1 if UEFI
    wpeutil UpdateBootInfo
    for /f "tokens=2* delims=     " %%A in ('reg query HKLM\System\CurrentControlSet\Control /v PEFirmwareType') DO SET Firmware=%%B
    :: Note: delims is a TAB followed by a space.
    if !Firmware!==0x1 set UEFI=0
    if !Firmware!==0x2 set UEFI=1
    
    if !UEFI! EQU 1 ( 
    %install%\setup.exe /unattend:%install%\EFI.xml /m:%install%\sources\EFI
    ) ELSE (
    %install%\setup.exe /unattend:%install%\MBR.xml /m:%install%\sources\MBR
    )
    exit
    And is the same error :(
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. Chibi ANUBIS

    Chibi ANUBIS MDL Chibi Developer

    Apr 28, 2014
    1,002
    663
    60
    #5 Chibi ANUBIS, Jun 29, 2016
    Last edited: Dec 16, 2019
    (OP)
    Pictures link dead...
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. Chibi ANUBIS

    Chibi ANUBIS MDL Chibi Developer

    Apr 28, 2014
    1,002
    663
    60
    IS FIXED !
    I missed he exist two setup.exe ... :eek:
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. wk-952

    wk-952 MDL Member

    Sep 2, 2012
    116
    286
    10
    Could you please explain further what was the issue ?
    I'm very curious about this.
     
  8. Chibi ANUBIS

    Chibi ANUBIS MDL Chibi Developer

    Apr 28, 2014
    1,002
    663
    60

    I realized after the boot.wim back that there were also a setup.exe, so logically the script that had the search will take this one and not that of the DVD and then can not find the xml file as it is in the DVD and not the boot.wim.

    To solve the problem I ask him to look for another file that does not exist in the boot.wim but only on DVD and there attribute the correct drive letter to start the xml file.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  9. mehdibleu

    mehdibleu MDL Expert

    Jun 14, 2017
    1,009
    247
    60
    #9 mehdibleu, Aug 21, 2017
    Last edited: Aug 21, 2017
    thank you for that script, it is a really smart script that allows to boot either from BIOS(MBR) or EFI according to user's bios configuration.
    I've tested it and it works great.

    And as i see but i'm not sure about this, you adjusted this script to be able to save time as you can directly lauch "sysprep.cmd" to capture the image after the installation of win10 is finished.

    if i'm correct, you tested this script on win10 configuration but i suppose that you can use it for all other windows versions.

    So back to the point i've just mentionned above, what about "install - windows 10.cmd" that you normally have to launch before "sysprep.cmd" in @AnarethoS script project ?
    did you adjust your script to be able to skip "install - windows 10.cmd" and run only "sysprep.cmd" ?
    or do you have to run "install - windows 10.cmd" as well before "sysprep.cmd" with your script to be able to make this work ?

    in other words, is it necessary to lauch "install - windows 10.cmd" just before running "sysprep.cmd" with your script ? or it is not necessary to launch "install - windows 10.cmd" anymore using your script ?
     
  10. Chibi ANUBIS

    Chibi ANUBIS MDL Chibi Developer

    Apr 28, 2014
    1,002
    663
    60
    Thank you I'm glad to see your comment :)
    My script works for all Windows, it is possible to remove "/m:%install%\sources\EFI" If you do not need to move a Recovery folder. Indeed with this method it is not necessary to run "Install - Windows 10.cmd" as the folder in question is already installed, you just have to put "ResetConfig.xml" of the Settings folder in the Recovery OEM folder before launching Sysprep.exe. The only difference is that the Recovery folder will not have the assignments that it gives "Install - Windows 10.cmd":
    Code:
    ATTRIB -S -R -H C:\Recovery
    ATTRIB -S -R -H C:\Recovery /S
    icacls C:\Recovery /reset /T /C
    icacls C:\Recovery /inheritance:r /grant:r SYSTEM:(OI)(CI)(F) /grant:r *S-1-5-32-544:(OI)(CI)(F) /grant:r *S-1-5-32-545:(OI)(CI)(RX) /C
    ATTRIB +S +H C:\Recovery
    
    Voilà ! :D
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  11. mehdibleu

    mehdibleu MDL Expert

    Jun 14, 2017
    1,009
    247
    60
    thank you for the reply but i didn't get the last sentence , what do you mean by "The only difference is that the Recovery folder will not have the assignments that it gives "Install - Windows 10.cmd".
    i see that you speak french, that's good news for me as i speak french as well, so if you could explain what you meant in this last sentence in french, that would be nice.:)
     
  12. Chibi ANUBIS

    Chibi ANUBIS MDL Chibi Developer

    Apr 28, 2014
    1,002
    663
    60
    In French is only message private please :)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  13. amulder31

    amulder31 MDL Novice

    Apr 30, 2017
    2
    0
    0
    Hello Chibi Anubis,
    I would be interested in your script edit as you did I try to do it without success it would be very nice to share it I'm also in France
    In advance thank you very much for your sharing
    cordially
    Amulder
     
  14. Chibi ANUBIS

    Chibi ANUBIS MDL Chibi Developer

    Apr 28, 2014
    1,002
    663
    60
    #14 Chibi ANUBIS, Dec 2, 2017
    Last edited: Dec 24, 2017
    (OP)
    Hello amulder31,
    I haven't files, is simply follow the post and download the OEM project by AnarethoS, It must be prepared before, I updated my thread, please tell me if you understand the process :)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  15. amulder31

    amulder31 MDL Novice

    Apr 30, 2017
    2
    0
    0
    Hello Chibi ANUBIS,
    Thank you very much I will try with your script good Sunday
     
  16. pacoolio

    pacoolio MDL Junior Member

    Jun 10, 2009
    97
    87
    0
    Is there an easier method to integrate all of this script in Windows 7 OEM ?
     
  17. Chibi ANUBIS

    Chibi ANUBIS MDL Chibi Developer

    Apr 28, 2014
    1,002
    663
    60
    #17 Chibi ANUBIS, Apr 9, 2018
    Last edited: Feb 25, 2020
    (OP)
    Hello ! For Windows 7 and Windows 8-8.1, you just need to prepare the install.cmd for partitioning your hard drive :
    Just remove the /m argument like : /m:%install%\sources\EFI and /m:%install%\sources\MBR

    Windows 7 IS ONLY FOR x64 !
    Because x86 don't run EFI, you don't need to patch the boot.wim, just put the MBR autounattend.xml

    winpeshl.ini
    Code:
    [LaunchApps]
    %SYSTEMDRIVE%\windows\system32\install.cmd
    
    install.cmd
    Code:
    @echo off
    SetLocal EnableDelayedExpansion
    
    FOR %%i IN (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST %%i:\efi.xml SET install=%%i:
    
    :Lastly do the UEFI detection
    :Check whether user has booted with UEFI or BIOS and set UEFI=1 if UEFI
    wpeutil UpdateBootInfo
    for /f "tokens=2* delims=     " %%A in ('reg query HKLM\System\CurrentControlSet\Control /v PEFirmwareType') DO SET Firmware=%%B
    :: Note: delims is a TAB followed by a space.
    if !Firmware!==0x1 set UEFI=0
    if !Firmware!==0x2 set UEFI=1
    
    if !UEFI! EQU 1 (
    %install%\setup.exe /unattend:%install%\efi.xml
    ) ELSE (
    %install%\setup.exe /unattend:%install%\mbr.xml
    )
    exit
    
    And Copy/Paste the Recovery folder in the root of your ISO, and copy this script Detection BIOS Mode in the Recovery folder. Rename Installer folder to GPT and MBR, this script will copy the folder in desktop, work also with Windows 8-8.1 :)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  18. Chibi ANUBIS

    Chibi ANUBIS MDL Chibi Developer

    Apr 28, 2014
    1,002
    663
    60
    #18 Chibi ANUBIS, Dec 29, 2018
    Last edited: Jun 19, 2020
    (OP)
    You can download here my PreConfig pack for make the Recovery on Windows 7-8-8.1-10 :

    WINDOWS 10 - ALL BUILDS DOWNLOAD
    RECOVERY PROJECT MDL BUILD 2006
    RECOVERY PROJECT MDL BUILD 2006 OEM
    SCANSTATE - ALL BUILDS
    UPDATER TOOLS DOWNLOAD
    Recovery Project Updater
    OLDS WINDOWS DOWNLOAD
    Recovery Tools for Windows 7
    Recovery Tools for Windows 8-8.1
    VERSION 2 :
    • Include my BIOS Mode detection.
    • Include ScanState.
    • Include ReadMe for installation.
    • Include Recovery Tools version 4.2.1 already prepare for MBR and EFI.
    • Include AddOn folder with : ESET Online Scanner and Yamicsoft Windows 10 Manager.
    REMEMBER : sysprep.cmd at need a confirmation to delete or not AddOn before the capture.

    About the OEM Edition :
    Allows you to install the information and theme of your computer's brand like the computers put for resale. Or you can custom OEM informations. You can see the demonstration here.

    About ScanState :
    Your ScanState version is must the same of your Windows installation Builds.
    You can download the old or last version of ScanState and put the software in ScanSate folder in C:\Recovery\OEM\ScanState

    EXPLICATION !
    • Use ScanStateDeploy.cmd if you update your ADK installed, this script can create a folder with the build number and copy all necessary files.
    • Use ScanStateUpdater.cmd for update your files installed if you have download the last build, this script update the Recovery Project with the last build. (Put the ScanState folder with the last build number in the same folder of ScanStateUpdater.cmd, this script can compare if you need update or not the ScanState installed.)
    About the Updater Tools :
    Allows you to update your old version of Recovery previously installed with the AnarethoS for Windows 10 method, it also makes it easier to make personal changes and deploy them.


    Changelog : Post-29
    Voilà ! :)
    [​IMG]
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  19. JeepWillys58

    JeepWillys58 MDL Member

    Nov 6, 2010
    196
    82
    10
    Hi Dear @Chibi ANUBIS ,

    There is a step-by-step to do it on the Windows 10 Enterprise LTSC 2019 comp 1809 17763.253?

    Thanks in advanced.

    Regards.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  20. Chibi ANUBIS

    Chibi ANUBIS MDL Chibi Developer

    Apr 28, 2014
    1,002
    663
    60
    Hello my friend, is the same method. Is work for all Windows 10 Edition.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...