Batch script to detect new hard drive

March 13, 2011 at 07:17:15
Specs: Windows server 2008 R2
I made a bootable usb with windowsPE and a sysprepped image on it.
I want to make a script that once the windowsPE is loaded, it will detect the new WD hard disk 150GB that i just plugged in to my computer, it will format it, create partition etc.. and assign a letter to it, and then i want to deploy and image on it (imagex /apply..).
How can i detect the new unformatted hard disk (if i have the size to detect or another "trick" to determine what is the new hard drive from the other drives..)
Its like i need to browse through all the harddrive (3 total), 2 are with data, and one is new from the shop, and i want to format and deploy and assign letter C to make it as my windows2008r2 server..
This is incase lets say my windows server hardisk is damaged and i want to reload it autmaticalliy with a pre made image file on a new drive i plug instead of the burned one :)

Thanks alot for answers !

everything is working fine(the bootable usb winPE and the image file), i just need to put all peices with a batch script code..

See More: Batch script to detect new hard drive

Report •

March 14, 2011 at 16:10:17

Report •

March 16, 2011 at 15:18:46
if you are little bit familier with scriprting Diskpart then use that, i will list the steps that you should step at a time, take output in text, process and then next step

1) list disk (take the output)
2) Prompt you to insert the drive now.
2) rescan
3) list disk (take the output and compare and with comparision get the value of new disk number)
4) select disk x (where x is the result of step 3)
5) create partition primary size= XXX (xxxx- your desired size)
6) select partition 1
7) active
8) assign letter x (X is the drive letter you want to assign)
9 ) exit (exit from diskpart)
10 ) format X: /q (X: is the drive letter you assigned in step 8)
11) imagex script to apply the wim image

** be careful with format and before procedding make sure the drive letter is correct.

Subhash Chandra.

Report •

Related Solutions

Ask Question