Here is a sample script to automate the process of deploying a master (or base) image to many other identical systems.
There are two scripts combined into one. The first script identifies the drive letter assigned to the volume "BOOTDISK", the second script identifies Hard Disk 0's unique ID.
::BD_drv_let.cmd ::A script to find the drive letter assigned to the volume labeled "BOOTDISK" ::Then set the environment variable "bootdisk" to this drive letter @echo off echo list vol > get_vols.txt diskpart /s get_vols.txt > vol_list.txt for /f "tokens=3 skip=1" %%i in ('find /i "bootdisk" vol_list.txt') do set bootdisk=%%i: ::dim_script.cmd ::A script to assign a new unique drive ID to a Disk Image script ::Assumes Disk 0 is the new target drive to receive the image ::Assumes image to restore is in BootDisk folder \user_files\ ::You may edit this variable out and supply your own drive letter
i.e. if using mapped drive. @echo off echo select disk 0 > get_disk_id.txt echo uniqueid disk >> get_disk_id.txt diskpart /s get_disk_id.txt > dskid.txt for /f "tokens=3" %%i in ('find /i "ID:" dskid.txt') do set newdiskid=%%i disk_image.exe /e a=restore fn1="%bootdisk%\user_files\DiskImage2.adi"
j1=restore_mbr t1=%newdiskid% dev1=0 clrpt1=1 kpt1=0 j2=restore_part t2=%newdiskid%:2048:1465145344
dev2=0 drv2=0 ia2=1 dl2=4 sy2=16 pt2=39 l="X:\DiskImage.log"
Some Notes: For information about Creating and Executing Scripts, please refer to that web page.
Since a generated Disk Image script contains the unique Disk ID of the original disk, a method is required to obtain the DISKID of a new target drive. The additional script is required to override the uniqueID in the DI script with a new DiskID.
Once you have created your script and saved the command line string, modify it to include the %newdiskid% variable.
It may be useful to know where the BOOTDISK volume is if \user_files\ contains an ‘.adi’ file to restore, otherwise it is not needed. You may substitute the variable %bootdisk% for your own drive letter.
A problem can occur if booting from a USB memory stick and WinPE assigns HDD 0 to memory stick. In this case you may consider using a bootable CD-R instead.