To use 7-Zip from the Windows 10 command line, install the 64-bit build from the official 7-Zip site, then call the console executable 7z.exe from a Command Prompt or PowerShell window. The quickest working command is 7z a archive.7z C:\Folder\*, which creates an archive from a folder. You do not need to add 7-Zip to your PATH if you run the command from its install folder or call the full path to 7z.exe.

What You'll Need

  • A Windows 10 PC with the 64-bit 7-Zip package installed from the official 7-Zip website. Use the .exe installer for your architecture; the 64-bit installer is labelled x64.
  • Access to Command Prompt or PowerShell. You do not need administrator rights for normal archive creation and extraction, but you do need write permission in the folder where you save the archive.
  • The path to the files or folders you want to compress, and a destination folder for the archive.

Step-by-Step

  1. Install 7-Zip 64-bit. Download the x64 .exe installer from the official 7-Zip site and run it. Accept the default install location, usually C:\Program Files\7-Zip. The installer adds both the graphical 7-Zip File Manager and the command-line program 7z.exe.
  2. Open a command window. Press the Windows key, type cmd or powershell, and press Enter. A normal window is fine for most archive work. Menu labels and the exact wording of prompts can differ slightly by Windows version and region.
  3. Go to the 7-Zip folder or use the full path. Either run cd "C:\Program Files\7-Zip" and then type 7z, or call the program by its full path, for example "C:\Program Files\7-Zip\7z.exe". Quotation marks matter because the folder name contains a space.
  4. Check that it runs. Type 7z and press Enter. You should see the 7-Zip banner and a list of commands. If Windows says the command is not recognized, you are not in the 7-Zip folder and did not use the full path.
  5. Create an archive. The basic form is 7z a archive.7z "C:\Path\To\Folder". The a command means add. Replace archive.7z with the name you want. To add every file inside a folder rather than the folder itself, use a wildcard such as "C:\Path\To\Folder\*".
  6. Choose a format if you need one. 7-Zip creates .7z by default. To make a ZIP file, add the switch -tzip, for example 7z a -tzip backup.zip "C:\Data\*". To make a .7z with maximum compression, add -mx=9.
  7. Extract an archive. Use the x command with the archive name and an output folder: 7z x archive.7z -o"C:\Output". Note there is no space after -o; the output path follows immediately. Use e instead of x only when you want all files flattened into one folder without their original folder structure.
  8. List contents before extracting. Run 7z l archive.7z to see what is inside without unpacking it. This is useful when you are not sure which archive you have.
  9. Test an archive. Run 7z t archive.7z to verify the archive is intact. This catches corruption before you rely on the backup.
  10. Update an existing archive. Run the same a command again with the existing archive name and the new files. 7-Zip adds or replaces changed files rather than rebuilding from scratch.

Common Mistakes

  • Omitting the quotation marks around paths that contain spaces, which makes 7-Zip treat part of the path as a separate argument.
  • Putting a space after -o when extracting. The output folder must follow the switch directly.
  • Running 7z from a folder other than the install folder without the full path, which produces a "not recognized" error.
  • Using e when you meant x, which flattens the folder structure and can overwrite files with the same name.
  • Assuming the 64-bit installer is required for command-line use. The 32-bit build also runs on 64-bit Windows, but the x64 build is the correct choice for a 64-bit system.

Tips

  • Add C:\Program Files\7-Zip to your PATH environment variable if you want to run 7z from any folder. Do this through the Windows environment variables settings, not by editing system files.
  • Use 7z -h to see the built-in help, and 7z a -h to see switches for the add command.
  • For scheduled backups, put the full path to 7z.exe in the task so it works regardless of the working directory.
  • Keep archives on a drive with enough free space; compression needs temporary room while it works.

Troubleshooting

If 7z is not recognized, confirm the install folder and use the full quoted path. If extraction fails with an access-denied error, check that you can write to the output folder and that the archive is not open in another program. If the archive is reported as corrupt, run 7z t on it; if the test fails, re-download or restore the archive from another copy. If a command appears to do nothing, check for a missing switch or a mistyped path, and run the command again with the archive name first. Restarting the command window after changing environment variables is also worth doing.

Frequently Asked Questions

Do I need the 64-bit version of 7-Zip on Windows 10?

The 64-bit build is the right choice for a 64-bit Windows 10 system. The 32-bit build still runs, but the x64 installer matches the operating system.

Where is 7z.exe installed?

By default it is in C:\Program Files\7-Zip. If you chose a different folder during install, use that path instead.

Can I create a ZIP file with 7-Zip from the command line?

Yes. Add the -tzip switch to the a command, for example 7z a -tzip backup.zip "C:\Data\*".

What is the difference between the x and e commands?

x extracts with the full folder structure. e extracts all files into a single folder and discards the original paths.

Does 7-Zip need administrator rights to run from the command line?

No for normal archive creation and extraction. You only need elevated rights if you are writing to a protected location such as Program Files.

How do I see what is inside an archive without extracting it?

Run 7z l archive.7z. The list command shows the file names, sizes and folder layout.