FG
💻 Software

How to check the exit code of the last command in batch file?

Fresh5 days ago
Mar 15, 2026200636 views
Confidence Score1%
1%

Problem

Inside a batch file on Windows, I use 7-zip like this: How could I check the exit code of and take the appropriate action ?

Error Output

...\right_path\7z a output_file_name.zip file_to_be_compressed

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How to check the exit code of the last command in batch file?

Low Risk

Test for a return code greater than or equal to 1: or or test for a return code equal to 0: You can use other commands such as where I show .

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment