# Scripted run

### From CGSecurity

TestDisk and PhotoRec can run automatically using their own built-in commands. A script file (such as .cmd or .bat 'Batch files' under MS-DOS/Windows, or some shell under Linux) may also be helpful.

This document describes the command line syntax.

## TestDisk

Syntax: `testdisk /cmd device cmd`

### Device selection

Use the device name, ie /dev/hda, /dev/hdb, /dev/sda.
For DOS version, use /dev/sda128 for first disk, /dev/sda129 for the second and so on...

### Partition type selection

- partition_i386
- partition_mac
- partition_none
- partition_sun
- partition_xbox

### Main menu

- advanced
- analyze
- delete
- geometry
- mbr_code
- options
- list

### Analyze menu

- backup
- list
- search
- write

### Advanced menu

- type
- boot
- superblock
- number: the partition number to select

#### FAT1x menu

- rebuildbs
- dump
- repairfat
- initroot

#### FAT32 menu

- rebuildbs
- dump
- repairfat
- originalfat
- backupfat

#### FAT rebuild menu

- list
- dump

#### NTFS menu

- rebuildbs
- dump
- originalntfs
- backupntfs

#### NTFS rebuild menu

- list
- dump

### Geometry menu

- C,number of cylinders
- H,number of heads
- S,number of sectors
- N,sector size

### Some examples

    testdisk /debug /log /cmd /dev/hda analyze,search

    testdisk /debug /log /cmd partition.dd options,partition_none,geometry,H,32,analyze,list,advanced,boot,rebuildbs,
    list partition.dd

## PhotoRec

Syntax: `photorec /cmd device cmd`

### Partition type selection

- partition_i386
- partition_mac
- partition_none
- partition_sun
- partition_xbox

### Main menu

- number: the partition number to select
- search
- options

### Options menu

- mode_ext2

### Some examples

    photorec /debug /log /cmd /dev/hdb select,search
    photorec /debug /log /cmd /dev/hda options,mode_ext2,5,search

Category: Data Recovery

##### Data Recovery

- TestDisk
- PhotoRec
- download