Call us now: 888 540-2010,  416 833-3501   10am – 6pm ET

All Script Commands

Disk Recycler home page


Command Description Example
Ata Execute a custom ATA command on the device. // Perform STANDBY IMMEDIATE command
Ata 0xE0 0 0 0
AtaIn Execute a custom ATA command and transfer data from the hard drive. // Perform IDENTIFY DEVICE command.
AtaIn 0xEC 0 0 1

Dump LastResult.Bytes
AtaOut Execute a custom ATA command and transfer data to the hard drive. bytes = new byte[512] 
bytes[0] = 0x37 
// WRITE DMA EXT Command: LBA=1200, write 1 sector
AtaOut 0x35 0 1200 1 bytes
// Read the same sector and dump contents to verify
ReadSectors 1200 1200 
Print LastResult
BadDisk Stops script execution with Failed status. if (LastResult.Error) 
   BadDisk
Capacity Reads capacity of the device in bytes. Capacity 
Print "Disk capacity = " LastResult
Checksum Performs checksum calculation of the entire media or specified range. Checksum MD5 1000 2000000 
Print "MD5 Checksum: " LastResult
Compare Compare sectors with the specified pattern. Compare AA55 0 1000000
Contains Indicates whether the soughtString occurs within this text. res = SmartTable
Contains res.Text "Head_Flying_Hours"
if (LastResult.OK)
  Print "Name of SMART attribute 240 is found."
Date Outputs current date and time into the report log. Date "yyyy-MM-dd HH:mm:ss"
DoD7Erase Performs DoD 5220.22-M 7-pass wiping of the entire media or the interval defined by startLBA and endLBA parameters. DoD7Erase 1000 2000
if (lastresult.OK)
  Print "Sectors 1000-2000 were wiped successfully."
else 
{
  Print "An error occurred during DoD erase of the specified range."
  Print LastResult
}
DoDErase Performs DoD 5220.22-M 3-pass wiping of the entire media or for the interval defined by startLBA and endLBA parameters. DoDErase FF00DD AA on
Dump Dumps a raw byte array as HEX codes. ReadDCO
Dump LastResult.Bytes
GoodDisk Stops script execution with Success status. if (LastResult.OK) 
   GoodDisk
Identify Runs IDENTIFY DEVICE command for ATA device. Identify 
Dump LastResult.Bytes
LastLBA Reads the number of the last LBA of the device. lastLbaRes = LastLBA 
prevSector = 0 
prevSector = lastLbaRes.Number - 1 
Scan prevSector lastLbaRes.Number   
LBAErase Wipes all the device space or for the interval defined by startLBA and endLBA parameters writing LBA numbers in the beginning of every sector. // Wipes first 200 sectors
LBAErase 0 199
Lock Executes SECURITY SET PASSWORD command with given parameters. Lock SecurePassword123 false true
if (LastResult.OK)
  Print "Device locked with password SecurePassword123 with maximum security level."
Locked Reads ID sector to verify if the deviced is locked by password. res = Locked
if (res.OK)
  Print "Disk is locked."
else
  Print "Disk is not locked."
Model Reads model of the hard drive. m = Model
Print m
NISTErase Performs NIST 800-88 wiping of the entire media or the interval defined by startLBA and endLBA parameters. It includes linear overwrite + full verification of written data according to the requirements of the 'National Institute of Standards and Technology: Draft NIST Special Publication 800-88 Revision 1' document. NISTErase 1000 2000
if (lastresult.OK)
  Print "Sectors 1000-2000 were wiped successfully."
else
  Print "An error occurred during NIST erase of the specified range."
PatternErase Performs wiping with specified pattern of the entire media or the interval defined by startLBA and endLBA parameters. // Wipes sectors 0-200 with HEX pattern 55AA
PatternErase 55AA true 0 200
PowerCycle Powers off and then powers on the hard drive. Identify
PowerCycle
Identify
PowerOff Powers off the hard drive. PowerOff
Sleep 1
PowerOn
PowerOn Powers on the hard drive. PowerOff
Sleep 1
PowerOn
Print Print the value of a variable to the report with a custom prefix. LastLba
Print "Last LBA number = " LastResult.Number
RandomNumber Generates a random integer value bounded by parameter maxValue. RandomNumber 1000
ReadSectors LastResult.Number LastResult.Number
ReadDCO Reads Raw Device Overlay Configuration sector of the device. ReadDCO
Dump LastResult.Bytes
ReadMaxAddressDCO Reads maximum LBA from Device Configuration Overlay. ReadMaxAddressDCO
Print LastResult.Number
ReadNativeMaxAddress Reads native maximum LBA. ReadNativeMaxAddress
Print LastResult.Number
ReadSectors Reads raw sector data from a range of sectors. Max allowed range is 1024 sectors. ReadSectors 10 1000
if (LastResult.OK)
  Dump LastResult.Bytes
Repair Performs media recovery. Software bad sectors will be recovered; hardware bad sectors will be reallocated (remapped), provided that the hard drive has spare sectors left on the media. // Remap all bad sectors in the LBA region 0 - 2 000 000
Repair 0 2000000
// Another example - simply repair the entire drive
// No parameters are needed in this case:
Repair
Report Creates custom report based on the specified template file. Parameters are passed to the template like this: {1} - first parameter, {2} - second parameter and so on. myVar1 = Model
myVar2 = "Some text"
Report MyTemplate myVar1.Text myVar2
Reset Performs hard disk reset. Reset
Identify
RestoreDCO Restores factory Device Overlay Configuration (DCO). hpaAddress = ReadNativeMaxAddress
dcoAddress = ReadMaxAddressDCO
if (dcoAddress.Number > hpaAddress.Number)
    RestoreDCO
Revision Reads firmware revision of the hard drive. r = Revision
Print r
Sas Execute a custom SCSI command on SAS device cdb = new byte[6]
cdb[0] = 0x1B
// START_STOP_UNIT: Spin down
Sas cdb  

// Setting up spin-up bit
cdb[4] = 1 
// START_STOP_UNIT: Spin up
Sas cdb
SasGList Reads SCSI device GList and checks if result exceeds limit.
SasIn Execute a custom data-in SCSI command and transfer data from SAS device. // Issue READ (10) SCSI command for LBA 1
read10 = new byte[10]
read10[0] = 0x28 
read10[5] = 0x01
read10[8] = 1
SasIn read10 512
SasOut Execute a custom SCSI command and transfer data to SAS device. // Issue WRITE (10) SCSI command for LBA 1
bytes = new byte[512]
bytes[1] = 0xDE
bytes[2] = 0xAD
bytes[3] = 0xBE
bytes[4] = 0xEF
cdb = new byte[10]
cdb[0] = 0x2a
cdb[5] = 0x01
cdb[8] = 0x01
SasOut cdb bytes
SasPList Reads SCSI device primary defect list (P-List).
SasReassign Executes REASSIGN BLOCKS command on given LBA creating defective logical block.
Scan Performs media scan of the entire media, or of the specified region. // Scan the entire media - no parameters are needed:
Scan
// More sophisticated example:
Scan 0 0xF00000
if (LastResult.OK)
  Print "Media surface up to LBA 0xF00000 is Ok."
else
  Print LastResult
SecurityErase Performs long-lasting Security Erase command that wipes the entire media. SecurityErase SecurePassword123
if (lastresult.OK)
  Print "Device was wiped succsessfully."
else
  Print "An error occurred during Security Erase."
SecurityEraseSupported Reads ID sector to verify if Security Erase command is supported by the device. res = SecurityEraseSupported
if (res.OK)
  Print "Security Erase command is supported."
else
  Print "Security Erase command is not supported."
SecurityStatus Reads ID sector to verify if the device is locked and which level it is locked with. res = SecurityStatus
if (res.Number == 0)
  Print "Device is not locked."
if (res.Number == 1)
  Print "Device is locked with High level."
if (res.Number == 2)
  Print "Device is locked with Maximum level."
Seek Performs seek test making 1-sector reads. // Perform random seek test within the first 600K sectors; 
// Timeout = 50 seconds
Seek random 50 0 600000
// Perform backward seek test within the last 600K sectors;
// Timeout = 50 seconds. We will need to perform some math to 
// calculate the range we need to test:
lastSector = LastLBA
firstSector = 0
firstSector = lastSector.Number - 600000
Seek backward 50 firstSector lastSector.Number
Serial Reads the serial number of the hard drive. s = Serial
Print s
SetCustomField Sets a value to current custom field. Can be successfully used only from custom field Script Code accessed via Settings->Data. LastLba
SetCustomField LastResult
SetExtendedResult Define Extended result. This is useful when you need to deviate from standard Success/Failed result and want to add a specific comment about the hard drive, for example, to define its Grade. Extended result will be saved into the database and shown on the report. It also allows to specify an alternative port color via default 6-symbol hex code with leading sharp symbol. Example: #95E5F5. Scan
if (LastResult.BlockCount > 0) {
   SetExtendedResult "Bad sectors found"
}
SetMaxAddress Limits the hard drive's capacity to the specified Maximum LBA (Set Max Address) // Caps disk size to 10000 sectors (5 Mbytes) by means of HPA
// Since the very first sector on the drive is 0 and not 1, 
// we need to set Max LBA to 9999 and not to 10000.
SetMaxAddress 9999
PowerOff
PowerOn
LastLba
Print "LastLBA = " LastResult
SetReadTimeout Sets timeout value used during any disk reading operation. Default read timeout is 20 seconds. // Set timeout equal to 2 seconds
SetReadTimeout 2000
SetWriteTimeout Sets timeout value used during any disk writing operation. Default write timeout is 20 seconds. // Set timeout equal to 3 seconds
SetWriteTimeout 3000
Sleep Pause the script for specified number of seconds. Sleep 10
Print "10 seconds elapsed."
SmartAttributeRaw Reads raw SMART value by attribute ID. res = SmartAttributeRaw 1 
Print "Raw read error rate value is " res
SmartAttributeThreshold Reads threshold SMART value by attribute ID. res = SmartAttributeThreshold 1 
Print "Raw read error rate threshold value is " res
SmartAttributeValue Reads normalized SMART value by attribute ID. res = SmartAttributeValue 1 
Print "Raw read error rate normalized value is " res
SmartAttributeWorst Reads worst SMART value by attribute ID. res = SmartAttributeWorst 1 
Print "Raw read error rate worst value is " res
SmartErrors Returns SMART error log page as text. res = SmartErrors 
Print res
SmartLog Shows SMART log page information depending on specified logType parameter. SmartLog selftest
SmartStatus Reads hard drive's SMART status. SmartStatus 
Print LastResult
SmartTable Reads the entire SMART attribute table. res = SmartTable 
Print res.Text
SmartTest Performs a SMART test. res = SmartTest short
Print res.Text
SpinDown Spins down the hard drive bringing it into standby mode. SpinDown
SpinUp
SpinUp Spins up the hard drive from the standby mode. SpinDown
SpinUp
SwitchAutoBadDisk Toggles automatic script termination on or off. SwitchAutoBadDisk true
Print "From this point any disk error will terminate the script with BadDisk status"
SwitchAutolog Toggles automatic logging on or off. SwitchAutolog true
Print "Now all commands will automatically print their Result to the report."
SwitchReadCache Toggles hard drive's read cache on or off. res = SwitchWriteCache false
if (res.OK)
  Print "Read look ahead is disabled."
SwitchSmart Toggles SMART on or off. res = SwitchSmart false
if (res.OK)
  Print "Smart has been disabled."
SwitchWriteCache Toggles hard drive's write cache on or off. res = SwitchWriteCache true
if (res.OK)
  Print "Cached writes are now enabled."
TextSearch Returns @LastResult.Text if searched substring is matched in @text or @LastResult.Number if number is parsed in the matched substring. Returns @LastResult.Error if no substring is matched. res = SmartTable
TextSearch res.Text "Data Structure revision number: ([\w]+)"
Print LastResult.Number
Time Returns the time in milliseconds since the moment the current script has started. t = Time 
Print t
TransferRate Performs transfer rate test executing read operations. The benchmark is performed for the inner, middle and outer tracks. For more precise results allow 30-60 seconds for testing. 20 seconds is considered sufficient for most applications. // Measure read transfer rate for 20 seconds
TransferRate 20
Print LastResult
UnclipHpaDco Removes max address restrictions from Host Protected Area (HPA) and Device Overlay Configuration (DCO). UnclipHpaDco
if (LastResult.Error)
    Print "Max address restriction removal error"
Unlock Permanently unlocks device with given parameters. Unlock SecurePassword123 false true
if (LastResult.OK)
  Print "Device was permanently unlocked with password SecurePassword123."
VerifySectors Verifies a sector range. Max allowed range is 1024 sectors. To verify the entire hard drive, use Scan command instead. VerifySectors 0 1000
if (LastResult.Error)
  Print LastResult
else
  Print "Media surface up to LBA 1000 is Ok."
WaitReadyTime Returns the time in milliseconds spent waiting for the hard drive to become ready after power on. res = WaitReadyTime
Print res
WriteDCO Write Raw Device Configuration Overlay (DCO). dco = ReadDCO
bytes = new byte[512]
bytes = dco.Bytes

// Decrease one of DCO Max LBA bytes
bytes[6]--
// Write change to DCO
WriteDCO bytes
WriteRandom Writes random data to interval defined by startLBA and endLBA parameters. WriteRandom 0 1000
if (LastResult.OK)
  Print "Sectors 0-1000 were filled with random data."
WriteSectors Fills a specified sector range with the predefined data (pattern). Max allowed range is 1024 sectors. To fill/wipe entire drive, use PatternErase command instead. data = new byte[512]
data[100] = 0xFF
WriteSectors 0 1000 data
if (LastResult.OK)
  Print "Data was written."
WriteTest Performs write test making 1-sector writes. // Perform random write test within the first 600K sectors; 
// Timeout = 50 seconds
WriteTest random 50 
// Perform backward write test within the last 600K sectors;
// Timeout = 50 seconds. We will need to perform some math to 
// calculate the range we need to test:
lastSector = LastLBA
firstSector = 0
firstSector = lastSector.Number - 600000
WriteTest backward 50 firstSector lastSector.Number
WriteTransferRate Performs transfer rate test executing write operations. The benchmark is performed for the inner, middle and outer tracks. For more precise results allow 30-60 seconds for testing. 20 seconds is considered sufficient for most applications. Binary zeroes by default or specified pattern are used for writing. // Measure write transfer rate for 40 seconds
WriteTransferRate 40
Print LastResult