> For the complete documentation index, see [llms.txt](https://documentation.hak5.org/hak5-usb-rubber-ducky/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.hak5.org/hak5-usb-rubber-ducky/advanced-features/payload-control.md).

# Payload Control

## Overview

In addition to the logic, loops and functions that provide complex payload control, a few additional commands exist to manipulate the execution of a payload.

## RESTART\_PAYLOAD

The `RESTART_PAYLOAD` command ceases any further execution, restarting the payload from the beginning.

### Example

```
REM Example RESTART_PAYLOAD

ATTACKMODE HID STORAGE
DELAY 2000

STRINGLN Hello, World!
RESTART_PAYLOAD

STRINGLN Nothing to see here.
```

#### Result

* The payload loop typing the "`Hello, World!`" line infinitely.
* The "`Nothing to see here.`" string will never be typed.

## STOP\_PAYLOAD

The `STOP_PAYLOAD` command ceases and further execution.

### Example

```
REM Example STOP_PAYLOAD

ATTACKMODE HID STORAGE
DELAY 2000

BUTTON_DEF
    STOP_PAYLOAD
END_BUTTON

WHILE TRUE
    RANDOM_CHARACTER
END_WHILE
```

#### Result

* The payload will continuously type a random character.
* Pressing the button will stop the payload.

## RESET

Not to be confused with the `RESTART_PAYLOAD` command, the will not change the payload flow. Rather, the `RESET` command will clear the HID keystroke buffer. This may be useful while debugging complex hold key states.

### Example

```
REM Example RESET

ATTACKMODE HID STORAGE
DELAY 2000

INJECT_MOD
HOLD SHIFT
HOLD a
DELAY 700
RELEASE a
RESET

DELAY 1000
STRING nd reset
```

#### Result

* On a Windows or Linux target, the payload may result in `AAAAAAAAAAAAnd reset`
* Notice that a `RELEASE SHIFT` command was omitted, and yet the `nd reset` string is lowercase. This is because the `RESET` command released all keys.
