# Exit Code

*noun*

say it: **“EG-zit KOHD”** **/ˈɛɡzɪt ˈkoʊd/**

A number a program gives back when it ends, 0 meaning it worked and any other number meaning it did not.

## What is an **exit code**?

An **exit code** is the number every program hands back when it finishes: 0 means it worked, and any other number means something went wrong, the number saying what. In PowerShell, `$LASTEXITCODE` holds the last program's exit code; in bash, `$?` does.

```powershell
where.exe robocopy
$LASTEXITCODE        # 0: it was found
```

## In a sentence

- “where.exe rsync ended with **exit code** 1, because there was no rsync.”
- “The script checks the program's **exit code** before it carries on.”

Level: Apprentice · [More Operating System terms at this level](https://www.ask-codey.com/glossary?category=operating-system&level=2)

Updated: November 10, 2026

## In other subjects

- [Exit Code in Unix](https://www.ask-codey.com/glossary/exit-code)

Source: https://www.ask-codey.com/glossary/exit-code-operating-system
