Solved Need Help With Scripting The Recovery Image Process

KYHI

Well-Known Member
Pro User
Messages
2,779
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 Computer

System One

  • OS
    Windows 3.1 > Windows 10
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Dell XPS 8700
    CPU
    I7
    Memory
    24 GB
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 Computer

System One

  • OS
    Windows 8 Pro
    System Manufacturer/Model
    ASRock 990FX Killer
    CPU
    AMD FX 8320
    Motherboard
    ASRock 990 FX Killer
    Memory
    32gb
    Graphics Card(s)
    Gigabyte GTX 750i
    Sound Card
    Realtek (Stock on MB)
    Monitor(s) Displays
    ASUS 27 HD Monitor & a 37" LCD HD TV Screen (For movies)
    Screen Resolution
    1920 x 1080
    Hard Drives
    1 250 GB SS hard drive for OS
    1 1TB hard drive for data / mirrored to a second 1 TB hd.
    PSU
    650W
    Case
    No name tower
    Cooling
    Enermax Liqtech 240
    Keyboard
    Logitech
    Mouse
    Logitech
    Internet Speed
    Dnload 10.48 Upload .48
    Browser
    IE 11 and Chrome when IE doesn't work
    Antivirus
    F-PROT
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 Computer

System One

  • OS
    Windows 3.1 > Windows 10
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Dell XPS 8700
    CPU
    I7
    Memory
    24 GB
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:

My Computer

System One

  • OS
    Windows 3.1 > Windows 10
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Dell XPS 8700
    CPU
    I7
    Memory
    24 GB
Great! Glad to have helped.
 

My Computer

System One

  • OS
    Windows 8 Pro
    System Manufacturer/Model
    ASRock 990FX Killer
    CPU
    AMD FX 8320
    Motherboard
    ASRock 990 FX Killer
    Memory
    32gb
    Graphics Card(s)
    Gigabyte GTX 750i
    Sound Card
    Realtek (Stock on MB)
    Monitor(s) Displays
    ASUS 27 HD Monitor & a 37" LCD HD TV Screen (For movies)
    Screen Resolution
    1920 x 1080
    Hard Drives
    1 250 GB SS hard drive for OS
    1 1TB hard drive for data / mirrored to a second 1 TB hd.
    PSU
    650W
    Case
    No name tower
    Cooling
    Enermax Liqtech 240
    Keyboard
    Logitech
    Mouse
    Logitech
    Internet Speed
    Dnload 10.48 Upload .48
    Browser
    IE 11 and Chrome when IE doesn't work
    Antivirus
    F-PROT
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:

My Computer

System One

  • OS
    Windows 3.1 > Windows 10
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Dell XPS 8700
    CPU
    I7
    Memory
    24 GB
Back
Top