Software⏱️ 3 min read📅 2026-06-11

How to Fix: Using 'ping' and 'findstr' in a 'for' loop of batch file first throws error not an internal external command but it again shows output

Batch file error: 'ping' and 'findstr' not recognized as internal or external commands, but works with hardcoded values.

Quick Answer: The issue is due to the environment variables containing the path of Sys32. To resolve it, add the path to the system's PATH variable before running the batch file.

The error 'ping' and 'findstr' not recognized as internal or external commands, operable program or batch file occurs when the batch file attempts to execute these commands without specifying their full path. This issue affects users who have placed these commands in a batch file and are using them for automation purposes.

This error can be frustrating because it prevents the batch file from functioning correctly, leading to unexpected results and potential data loss. Fortunately, this problem can be resolved by ensuring that the commands are executed with their full path or by modifying the environment variables to include the path of the Sys32 directory.

⚠️ Common Causes

  • The primary reason for this error is that the batch file is not specifying the full path of the 'ping' and 'findstr' commands. This can happen when these commands are used in a script and the user assumes they will be recognized by default.
  • Another possible cause is that the environment variables have been modified to exclude the path of the Sys32 directory, which contains the 'ping' and 'findstr' commands.

🔧 Proven Troubleshooting Steps

Specify full path of 'ping' and 'findstr' commands

  1. Step 1: Open the Command Prompt and navigate to the location where the batch file is stored. This will help you determine the correct path for the 'ping' and 'findstr' commands.
  2. Step 2: Modify the batch file to specify the full path of the 'ping' and 'findstr' commands, like this: ping C:\Windows\System32\ping.exe -n %qosping% > temp.txt
  3. Step 3: Save the changes to the batch file and test it again to verify that the error has been resolved.

Modify environment variables to include Sys32 path

  1. Step 1: Open the System Properties by right-clicking on 'This PC' or 'Computer' and selecting 'Properties'. Click on 'Advanced system settings' on the left side.
  2. Step 2: Click on 'Environment Variables' and then click on 'Path' under the 'System Variables' section. Click 'Edit' to modify the path.
  3. Step 3: Add the path of the Sys32 directory to the list, like this: C:\Windows\SysWOW64;C:\Windows\System32
  4. Step 4: Save the changes and close all windows. Test the batch file again to verify that the error has been resolved.

💡 Conclusion

To resolve the 'ping' and 'findstr' not recognized as internal or external commands, operable program or batch file issue, it is recommended to specify the full path of these commands in the batch file or modify the environment variables to include the Sys32 directory. By following these steps, users can ensure that their batch files function correctly and produce expected results.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions