How to Use 7-Zip from the Command Line

Automate archive operations with the 7z command-line tool.

Advanced
  1. 1

    Locate 7z.exe

    The command-line tool is installed at C:\Program Files\7-Zip\7z.exe. Add this path to your system PATH for easy access, or use the full path.

  2. 2

    Open a terminal

    Open Command Prompt, PowerShell, or Windows Terminal. Type "7z" to see available commands.

  3. 3

    Create an archive

    Use: 7z a archive.7z file1 file2 — This adds files to an archive. The "a" command means "add".

  4. 4

    Extract an archive

    Use: 7z x archive.7z -oC:\output — The "x" command extracts with full paths. -o specifies the output directory (no space after -o).

  5. 5

    List archive contents

    Use: 7z l archive.7z — The "l" command lists files inside the archive without extracting.

  6. 6

    Test archive integrity

    Use: 7z t archive.7z — The "t" command tests the archive for errors and CRC integrity.

Was this helpful?