Skip to content Skip to main navigation Skip to footer

Batch File Sample for Restoring all Partitions on a Hard Drive

The batch file included below may be used to run Image for DOS to restore several partitions. The batch file is internally documented, and should be easy to customize to your needs.

To use the batch file, copy the content below, paste it into a text editor such as Notepad, and save the file with the .BAT file extension.

@echo off
cls

:: Copyright (C) 2007, TeraByte Unlimited.  All rights reserved.

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: This script invokes Image for DOS (IFD) to restore multiple partitions.
::
:: Note that you may want to use the N command line option in each command
:: line except the last one.  The N option suppresses the prompt to reboot
:: after a restore operation completes.  By using the N option in each command
:: line except the last one, you can avoid being prompted to reboot until all
:: the restore processes have completed.
::
:: You may also wish to use the /C command line parameter in the first command
:: line.  The /C option clears the MBR and EMBR prior to restore.
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: The imgfileX and sourceX variables below require customization.
:: Remove or comment out unneeded variables, or add more if needed.
::
:: Some examples:
::
::    set imgfile1=part01
::
:: The command above tells the script that the image file used to restore the
:: first partition is named part01. (Do not supply any file extension.)
::
::    set source1=001:\%imgfile1%
::
:: The command above specifies that partition ID 01 on hard drive 0 is where
:: imgfile1 (part01) is located.
::
::    set source1=/cd1%imgfile1%
::
:: The command above specifies that imgfile1 (part01) is to be restored from
:: CD/DVD drive 1.
::
:: Please refer to the applicable product manual for more information on valid
:: command line format.

set imgfile1=
set source1=

set imgfile2=
set source2=

set imgfile3=
set source3=

:: The message below will be displayed on screen briefly as IFD loads.

echo.
echo Running Image for DOS, please wait...

:: The /C parameter is used here to clear the MBR/EMBR.
:: The N option is used here to suppress the reboot prompt.

set el1=0
image.exe /rn /c %source1%
if errorlevel 1 set el1=1

echo.
echo Running Image for DOS, please wait...

:: The N option is used here to suppress the reboot prompt.

set el2=0
image.exe /rn %source2%
if errorlevel 1 set el2=1

echo.
echo Running Image for DOS, please wait...

set el3=0
image.exe /r %source3%
if errorlevel 1 set el3=1

echo.
if "%el1%"=="0" echo The restore of %imgfile1% completed successfully.
if "%el1%"=="1" echo ### An error occurred during restore of %imgfile1%. ###

echo.
if "%el2%"=="0" echo The restore of %imgfile2% completed successfully.
if "%el2%"=="1" echo ### An error occurred during restore of %imgfile2%. ###

echo.
if "%el3%"=="0" echo The restore of %imgfile3% completed successfully.
if "%el3%"=="1" echo ### An error occurred during restore of %imgfile3%. ###

echo.
pause

set imgfile1=
set imgfile2=
set imgfile3=
set el1=
set el2=
set el3=
set source1=
set source2=
set source3=

:: End of script

Was This Article Helpful?

0