Coding⏱️ 3 min read📅 2026-06-19

How to Fix: Script working but throwing 'The syntax of the command is incorrect.' error

The script is throwing a 'The syntax of the command is incorrect.' error due to a missing delimiter in the FOR /F loop.

Quick Answer: Add a space after the `eol=#` option in the FOR /F loop to fix the error.

The 'The syntax of the command is incorrect.' error occurs when the script tries to parse arguments using the FOR /F loop, but the format of the settings file (%~f1) is not correct. This error affects users who are trying to use this script to create a 7-Zip backup.

This error can be frustrating because it prevents the script from running successfully and creating the desired backup. However, with the following steps, you should be able to resolve the issue and get your backup working again.

🔍 Why This Happens

  • The main reason for this error is that the settings file (%~f1) contains incorrect or missing data. The FOR /F loop expects a specific format for the settings file, which includes equal signs (=) between each setting. If the settings file does not follow this format, the script will throw an error.
  • Another possible cause of this error is that the settings file (%~f1) contains invalid or missing data types. For example, if the 'Archive Type' setting is specified as a string value instead of a valid archive type (e.g., zip, 7z), the script will not be able to parse it correctly.

🚀 How to Resolve This Issue

Correcting the settings file format

  1. Step 1: Open the settings file (%~f1) in a text editor and verify that each setting is separated by an equal sign (=). If necessary, remove any unnecessary or invalid data from the settings file.
  2. Step 2: Check that the 'Archive Type' setting is specified correctly. Make sure it is one of the valid archive types supported by 7-Zip (e.g., zip, 7z).
  3. Step 3: Save the corrected settings file and try running the script again.

Verifying the data types in the settings file

  1. Step 1: Open the settings file (%~f1) in a text editor and verify that each setting has a valid data type. For example, if the 'Archive Type' setting is specified as a string value, make sure it is enclosed in quotes (e.g., "zip").
  2. Step 2: Check that all other settings have correct data types. If necessary, update or remove any invalid data from the settings file.
  3. Step 3: Save the corrected settings file and try running the script again.

🎯 Final Words

By following these steps, you should be able to resolve the 'The syntax of the command is incorrect.' error and get your 7-Zip backup working again. Remember to double-check your settings file for any errors or invalid data before trying again.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions