Windows 8 and 8.1 Forums


Need Help With Scripting The Recovery Image Process

  1. #1


    Posts : 2,690
    Windows 3.1 > Windows 10

    Need Help With Scripting The Recovery Image Process


    I am try to run a script from my WinPE USB drive - when running the following script - it blows (scrolls) right through it.. I am missing something and the root drive for the file needing to be copied is the winpe drive - it does not stop to give me the choice of bios or uefi - you'll get the jist of the script.. Thanks..

    cls
    ECHO.
    ECHO ===============================================================================
    ECHO.
    ECHO. Select The Partition Structure Type To Create A Recovery Image
    ECHO. Press 'B' For BIOS, Press 'U' For UEFI, Press 'C' to Cancel
    ECHO.
    ECHO ===============================================================================
    ECHO.
    choice /c buc /n /m "Select BIOS, UEFI or CANCEL"
    IF %ERRORLEVEL%==1 GOTO :BIOS
    IF %ERRORLEVEL%==2 GOTO :UEFI
    IF %ERRORLEVEL%==3 GOTO :QUIT
    :BIOS
    cls
    ECHO.
    ECHO ===============================================================================
    ECHO.
    ECHO. Creating The System Recovery Image
    ECHO. Relax This May Take A While
    ECHO.
    ECHO ===============================================================================
    ECHO.
    diskpart /s %root%\z-scripts\bios\assignletters.txt
    exit
    md R:\RecoveryImage
    Copy %root%\z-scripts\bois\resetpartitions.txt r:\recoveryimage
    Copy %root%\z-scripts\bois\ResetConfig.xml r:\recoveryimage
    W:\Windows\System32\Reagentc /Setosimage /Path R:\RecoveryImage /Target W:\Windows /Index 1
    Dism /Capture-Image /CaptureDir:W:\ /ImageFile:R:\RecoveryImage\Install.wim /Name:"Windows"
    goto :QUIT
    :UEFI
    cls
    ECHO.
    ECHO ===============================================================================
    ECHO.
    ECHO. Creating The System Recovery Image
    ECHO. Relax This May Take A While
    ECHO.
    ECHO ===============================================================================
    ECHO.
    diskpart /s %root%\z-scripts\uefi\assignletters.txt
    md R:\RecoveryImage
    Copy %root%\z-scripts\uefi\resetpartitions.txt r:\recoveryimage
    Copy %root%\z-scripts\uefi\ResetConfig.xml r:\recoveryimage
    W:\Windows\System32\Reagentc /Setosimage /Path R:\RecoveryImage /Target W:\Windows /Index 1
    Dism /Capture-Image /CaptureDir:W:\ /ImageFile:R:\RecoveryImage\Install.wim /Name:"Windows"
    goto :QUIT
    :QUIT
    cls
    ECHO.
    ECHO ===============================================================================
    ECHO.
    ECHO. Would You Like To REBOOT The System
    ECHO.
    ECHO ===============================================================================
    ECHO.
    choice /c yn /n /m "Select YES or NO"
    IF %ERRORLEVEL%==1 GOTO :REBOOT
    IF %ERRORLEVEL%==2 GOTO :EXIT
    :EXIT
    Exit
    :REBOOT
    exit
    exit

      My System SpecsSystem Spec

  2. #2


    Is the "CHOICE.EXE" on the WinPE usb drive? If it is not prompting you, then I would look for the choice.exe file and copy it to your USB drive. On a normal win7 computer you will find choice.exe in c:\windows\system32. Hope this helps.
      My System SpecsSystem Spec

  3. #3


    Posts : 2,690
    Windows 3.1 > Windows 10


    Added Choice to the WinPE image and that works.. thank you..

    now it starts to load diskpart - but is appears my reference to the script is incorrect.. because it exits
    I am running the .bat file from USB\ and the script is located in USB\z-scripts\folder

    since the drive letter will change depending on system configuration - I need the syntax to tell it use the current USB drive letter > syntax\z-scripts\folder

    WinPE is drive X and my script files are in drive USB\\

    So I assume I am calling for the script in X and thus not finding it in USB
      My System SpecsSystem Spec

  4. #4


    Posts : 2,690
    Windows 3.1 > Windows 10


    I got it > Had to add choice.exe to WinPE > Had to change %root% to %~dp0 > had to fix a typo > removed an exit or two..

    cls
    @echo off
    ECHO.
    ECHO ===========================================================================
    ECHO.
    ECHO. Select The Partition Structure Type To Create A Recovery Image
    ECHO.
    ECHO ===========================================================================
    ECHO.
    choice /c buc /n /m "Select (B)IOS, (U)EFI or (C)ANCEL"
    IF %ERRORLEVEL%==1 GOTO :BIOS
    IF %ERRORLEVEL%==2 GOTO :UEFI
    IF %ERRORLEVEL%==3 GOTO :QUIT
    :BIOS
    cls
    ECHO.
    ECHO ===========================================================================
    ECHO.
    ECHO. Creating The System Recovery Image
    ECHO. Relax This May Take A While
    ECHO.
    ECHO ===========================================================================
    ECHO.
    diskpart /s %~dp0\z-scripts\bios\assignletters.txt
    md R:\RecoveryImage
    Copy %~dp0\z-scripts\bios\resetpartitions.txt r:\recoveryimage
    Copy %~dp0\z-scripts\bios\ResetConfig.xml r:\recoveryimage
    W:\Windows\System32\Reagentc /Setosimage /Path R:\RecoveryImage /Target W:\Windows /Index 1
    Dism /Capture-Image /CaptureDir:W:\ /ImageFile:R:\RecoveryImage\Install.wim /Name:"Windows"
    goto :QUIT
    :UEFI
    cls
    ECHO.
    ECHO ===========================================================================
    ECHO.
    ECHO. Creating The System Recovery Image
    ECHO. Relax This May Take A While
    ECHO.
    ECHO ===========================================================================
    ECHO.
    diskpart /s %~dp0\z-scripts\uefi\assignletters.txt
    md R:\RecoveryImage
    Copy %~dp0\z-scripts\uefi\resetpartitions.txt r:\recoveryimage
    Copy %~dp0\z-scripts\uefi\ResetConfig.xml r:\recoveryimage
    W:\Windows\System32\Reagentc /Setosimage /Path R:\RecoveryImage /Target W:\Windows /Index 1
    Dism /Capture-Image /CaptureDir:W:\ /ImageFile:R:\RecoveryImage\Install.wim /Name:"Windows"
    goto :QUIT
    :QUIT
    cls
    ECHO.
    ECHO ===========================================================================
    ECHO.
    ECHO. Operation Complete! Would You Like To REBOOT The System
    ECHO.
    ECHO ===========================================================================
    ECHO.
    choice /c yn /n /m "Select (Y)ES or (N)O"
    IF %ERRORLEVEL%==1 exit
    IF %ERRORLEVEL%==2 @echo on
    Last edited by KYHI; 13 Nov 2014 at 22:35.
      My System SpecsSystem Spec

  5. #5


    Great! Glad to have helped.
      My System SpecsSystem Spec

  6. #6


    Posts : 2,690
    Windows 3.1 > Windows 10


    Well I finished my project - the program script allows me to create MBR and GPT hard drive partitions with a recovery image partition. The script also allows me to install 3 different versions of windows. and lastly it allows me to capture a recovery (push button reset) image. which can then be used to create recovery media..

    Here is the Menu Snippet:
    (A) CREATE A "BIOS_MBR TYPE" PARTITION STRUCTURE
    (B) CREATE A "UEFI_GPT TYPE" PARTITION STRUCTURE
    (C) CAPTURE AND CREATE A "BIOS_MBR TYPE" RECOVERY
    (D) CAPTURE AND CREATE A "UEFI TYPE" RECOVERY
    (I) INSTALL MICROSOFT WINDOWS FROM THIS USB DRIVE
    (X) QUIT THIS PROGRAM

    WinPE 5.1 was the preinstallation environment use for testing
    Last edited by KYHI; 25 Nov 2014 at 18:14.
      My System SpecsSystem Spec

Need Help With Scripting The Recovery Image Process
Related Threads
How to Do a System Image Recovery in Windows 8 and 8.1 This tutorial will show you how to restore the contents of your Windows 8 or 8.1 PC back to how it was at the time a system image was created if your hard disk or entire computer ever stops working. You can only do a system image...
Well I finished my project - the program script allows me to create MBR and GPT hard drive partitions with a recovery image partition. The script also allows me to install 3 different versions of windows. and lastly it allows me to capture a recovery (push button reset) image. which can then be...
After upgrading to 8.1 i see two recovery partitions: see attachment ...
Can not set custom recovery image in Performance & Maintenance
Hello gang. I created a custom refresh image the day before upgrading to 8.1. I am having shut down and sleep issues with windows 8.1 that I don't have time to troubleshoot any longer and I wish to go back to win 8 for now. I went to check that my image was there and active and this is what i get:...
Recovery image not found in Installation & Setup
Ok, been scouring the Web for a little over a month now. I am now sure I have recovery images. Factory, and refresh. Asus shipped no recovery media. I obtained a copy of windows 8. I found out what my product key is. I have attempted every which way i can think of to get my system to recognize my...
Windows 8 image/recovery in Performance & Maintenance
Hello all, I am new to this forum, and what a great place. I have enjoyed reading lots and trying some of the tutorials. However, I am having dramas, my computer keeps crashing. I am running windows 8 Pro. I am not a "newbie" to computing but I am not a "geek" (I don't think). What I am...
I've been dual-booting Windows 8 Pro and Windows 7 Ultimate, but a while back my Windows 8 kind of went "South" and wouldn't boot at all (I got an error message that a device was "not attached"). I have a recent system image on an external USB hard drive, but when I boot to "system recovery" using...
Eight Forums Android App Eight Forums IOS App Follow us on Facebook