{"id":336,"date":"2007-08-23T04:40:00","date_gmt":"2007-08-23T11:40:00","guid":{"rendered":"https:\/\/kb.terabyteunlimited.com\/kb-articles\/batch-file-sample-for-restoring-all-partitions-on-a-hard-drive\/"},"modified":"2021-09-07T21:57:27","modified_gmt":"2021-09-08T04:57:27","slug":"batch-file-sample-for-restoring-all-partitions-on-a-hard-drive","status":"publish","type":"lsvr_kba","link":"https:\/\/www.terabyteunlimited.com\/kb\/kb-articles\/batch-file-sample-for-restoring-all-partitions-on-a-hard-drive\/","title":{"rendered":"Batch File Sample for Restoring all Partitions on a Hard Drive"},"content":{"rendered":"<p>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.<br \/>\r\n<br \/>\r\nTo 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.<br \/>\r\n<br \/>\r\n@echo off<br \/>\r\ncls<br \/>\r\n<br \/>\r\n:: Copyright (C) 2007, TeraByte Unlimited.\u00a0 All rights reserved.<br \/>\r\n<br \/>\r\n::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::<br \/>\r\n:: This script invokes Image for DOS (IFD) to restore multiple partitions.<br \/>\r\n::<br \/>\r\n:: Note that you may want to use the N command line option in each command<br \/>\r\n:: line except the last one.\u00a0 The N option suppresses the prompt to reboot<br \/>\r\n:: after a restore operation completes.\u00a0 By using the N option in each command<br \/>\r\n:: line except the last one, you can avoid being prompted to reboot until all<br \/>\r\n:: the restore processes have completed.<br \/>\r\n::<br \/>\r\n:: You may also wish to use the \/C command line parameter in the first command<br \/>\r\n:: line.\u00a0 The \/C option clears the MBR and EMBR prior to restore.<br \/>\r\n::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::<br \/>\r\n<br \/>\r\n:: The imgfileX and sourceX variables below require customization.<br \/>\r\n:: Remove or comment out unneeded variables, or add more if needed.<br \/>\r\n::<br \/>\r\n:: Some examples:<br \/>\r\n::<br \/>\r\n::\u00a0\u00a0\u00a0 set imgfile1=part01<br \/>\r\n::<br \/>\r\n:: The command above tells the script that the image file used to restore the<br \/>\r\n:: first partition is named part01. (Do not supply any file extension.)<br \/>\r\n::<br \/>\r\n::\u00a0\u00a0\u00a0 set source1=001:&#92;%imgfile1%<br \/>\r\n::<br \/>\r\n:: The command above specifies that partition ID 01 on hard drive 0 is where<br \/>\r\n:: imgfile1 (part01) is located.<br \/>\r\n::<br \/>\r\n::\u00a0\u00a0\u00a0 set source1=\/cd1%imgfile1%<br \/>\r\n::<br \/>\r\n:: The command above specifies that imgfile1 (part01) is to be restored from<br \/>\r\n:: CD\/DVD drive 1.<br \/>\r\n::<br \/>\r\n:: Please refer to the applicable product manual for more information on valid<br \/>\r\n:: command line format.<br \/>\r\n<br \/>\r\nset imgfile1=<br \/>\r\nset source1=<br \/>\r\n<br \/>\r\nset imgfile2=<br \/>\r\nset source2=<br \/>\r\n<br \/>\r\nset imgfile3=<br \/>\r\nset source3=<br \/>\r\n<br \/>\r\n:: The message below will be displayed on screen briefly as IFD loads.<br \/>\r\n<br \/>\r\necho.<br \/>\r\necho Running Image for DOS, please wait...<br \/>\r\n<br \/>\r\n:: The \/C parameter is used here to clear the MBR\/EMBR.<br \/>\r\n:: The N option is used here to suppress the reboot prompt.<br \/>\r\n<br \/>\r\nset el1=0<br \/>\r\nimage.exe \/rn \/c %source1%<br \/>\r\nif errorlevel 1 set el1=1<br \/>\r\n<br \/>\r\necho.<br \/>\r\necho Running Image for DOS, please wait...<br \/>\r\n<br \/>\r\n:: The N option is used here to suppress the reboot prompt.<br \/>\r\n<br \/>\r\nset el2=0<br \/>\r\nimage.exe \/rn %source2%<br \/>\r\nif errorlevel 1 set el2=1<br \/>\r\n<br \/>\r\necho.<br \/>\r\necho Running Image for DOS, please wait...<br \/>\r\n<br \/>\r\nset el3=0<br \/>\r\nimage.exe \/r %source3%<br \/>\r\nif errorlevel 1 set el3=1<br \/>\r\n<br \/>\r\necho.<br \/>\r\nif \"%el1%\"==\"0\" echo The restore of %imgfile1% completed successfully.<br \/>\r\nif \"%el1%\"==\"1\" echo ### An error occurred during restore of %imgfile1%. ###<br \/>\r\n<br \/>\r\necho.<br \/>\r\nif \"%el2%\"==\"0\" echo The restore of %imgfile2% completed successfully.<br \/>\r\nif \"%el2%\"==\"1\" echo ### An error occurred during restore of %imgfile2%. ###<br \/>\r\n<br \/>\r\necho.<br \/>\r\nif \"%el3%\"==\"0\" echo The restore of %imgfile3% completed successfully.<br \/>\r\nif \"%el3%\"==\"1\" echo ### An error occurred during restore of %imgfile3%. ###<br \/>\r\n<br \/>\r\necho.<br \/>\r\npause<br \/>\r\n<br \/>\r\nset imgfile1=<br \/>\r\nset imgfile2=<br \/>\r\nset imgfile3=<br \/>\r\nset el1=<br \/>\r\nset el2=<br \/>\r\nset el3=<br \/>\r\nset source1=<br \/>\r\nset source2=<br \/>\r\nset source3=<br \/>\r\n<br \/>\r\n:: End of script<br \/>\r\n<br \/>\r\n<\/p>","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"lsvr_kba_cat":[1818],"lsvr_kba_tag":[],"class_list":["post-336","lsvr_kba","type-lsvr_kba","status-publish","hentry","lsvr_kba_cat-ifd-ifl-ifw-version-1-archive"],"_links":{"self":[{"href":"https:\/\/www.terabyteunlimited.com\/kb\/wp-json\/wp\/v2\/lsvr_kba\/336","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.terabyteunlimited.com\/kb\/wp-json\/wp\/v2\/lsvr_kba"}],"about":[{"href":"https:\/\/www.terabyteunlimited.com\/kb\/wp-json\/wp\/v2\/types\/lsvr_kba"}],"author":[{"embeddable":true,"href":"https:\/\/www.terabyteunlimited.com\/kb\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.terabyteunlimited.com\/kb\/wp-json\/wp\/v2\/comments?post=336"}],"version-history":[{"count":1,"href":"https:\/\/www.terabyteunlimited.com\/kb\/wp-json\/wp\/v2\/lsvr_kba\/336\/revisions"}],"predecessor-version":[{"id":6468,"href":"https:\/\/www.terabyteunlimited.com\/kb\/wp-json\/wp\/v2\/lsvr_kba\/336\/revisions\/6468"}],"wp:attachment":[{"href":"https:\/\/www.terabyteunlimited.com\/kb\/wp-json\/wp\/v2\/media?parent=336"}],"wp:term":[{"taxonomy":"lsvr_kba_cat","embeddable":true,"href":"https:\/\/www.terabyteunlimited.com\/kb\/wp-json\/wp\/v2\/lsvr_kba_cat?post=336"},{"taxonomy":"lsvr_kba_tag","embeddable":true,"href":"https:\/\/www.terabyteunlimited.com\/kb\/wp-json\/wp\/v2\/lsvr_kba_tag?post=336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}