title: Clearing sector zero of a removable media device
body: <p>I need to clear sector 0 for removable media devices (custom USB memory devices) which I have been trying to clear within a WPF/C# application.  My first attempt was to use <a href="http://www.chrysocome.net/dd" rel="nofollow">DD</a>, but I ran into problems.  During the manufacturing of the devices a MBR is created at sector 0 and the volume (logical?) starts at sector 40.  When I issue the following command it clears sector 40 and not sector 0:
  <br><br>
  <code>dd bs=512 count=1 if=/dev/zero of=\.\E:</code>
  <br><br>
  I found another version of DD <a href="http://gmgsystemsinc.com/fau/" rel="nofollow">here</a> which includes a wipe utility.  I tried this version and I am seeing the same behavior.  I am using both HxD and Runtime's DiskExplorer that sector 40 is being cleared and not sector 0.  I could use HxD or Runtime's DiskExplorer, but this needs to be scriptable.
  <br><br>
  Does anyone know of any other methods of clearing (filling) sector 0 within Windows XP SP2??  Any help would be greatly appreciated. Thanks.</p>
  
  <p>Mark
  <BR><BR>
  Solution: My solution used WMI to find the physical drive based upon the logical drive letter.  First, query the Win32_LogicalDiskToPartition class to find the logical drive I am looking for. This provides the Antecedent field which constains something like '...DeviceID="Disk #X, Partition #Y"'.  Next, I query Win32_DiskDriveToDiskPartition class while searching against the Dependent field to find the match for the Antecedent field within the Win32_LogicalDiskToPartition class.  Once found, the Antecedent field from Win32_LogicalDiskToPartition will yield the physical drive. I selected atzz since it is the closes to my solution.  I wanted to use Eugene's suggestion, but I only had a few hours to implement this so I selected the easier of the two.  I will need to revisit this at a later time though.</p>