# 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
- ask_type: the user will be asked for the partition type

### Main menu

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

### Analyse menu

- backup
- mode_vista: search for partitions created by Windows Vista Disk Manager
- list
- search
- noconfirm
- 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
- repairmft

#### 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
- ask_type: the user will be asked for the partition type

### Main menu

- fileopt: Let's change files type to recover
- inter: PhotoRec usage becomes interactif
- options
- number: the partition number to select
- blocksize: force the blocksize, it's followed by the blocksize in bytes.
- search

### Options menu

- mode_ext2

### Some examples

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

Category: Data Recovery

##### Data Recovery

- TestDisk
- PhotoRec
- download