SOLVED: exec: "cmd": executable file not found in %PATH%

After coming across this error while compiling for an ESP32 board, looking for and trying out many various suggestions (except re-installing Arduino IDE) to solve it, I thought that maybe just copying the cmd.exe file from my C:\Windows\System32 folder to my C:\Program Files (x86)\Arduino would work and IT DID.
Basically, copying the cmd.exe to the same folder where your arduino.exe is located should solve the problem.
So, I am sharing this workaround here for those who are frustrated with this problem while finding no quick workable solutions.
I am almost sure there is a misdirected/corrupted pointer to cmd.exe somewhere in the Arduino IDE installation, but I don't know enough at this moment to find and correct it.

1 Like

Hi @Edin_Fific. Thanks for taking the time to share the solution you found!

I don't think it is a problem in Arduino IDE. Instead it is a deficiency with your Windows configuration.

The ESP32 boards platform uses the Windows command processor (cmd.exe) during the compilation process. It is assumed that you have the path to cmd.exe in your system Path environment variable, as is standard.

This error indicates that you have some unusual configuration of Windows that causes the path to cmd.exe to not be in your system Path environment variable. You can fix the problem by adding that path to the environment variable. The most significant benefit to my solution is that it will persist through Arduino IDE updates. I also fear that your solution might not work in the case where Arduino IDE is started from another folder (which might occur if you start Arduino IDE by opening a .ino file via file association instead of by launching the IDE directly?).

I'll provide instructions for my solution:

  1. Right click the "Start" icon on the left side of the Windows taskbar
  2. Select "System" from the menu.
    The "Settings" window will open.
  3. Click the "Advanced system settings" link you find under the "Related Links" (or "Related Settings" if you are using Windows 10) section of the "Settings" window.
  4. If you get a "User Account Control" dialog, click the Yes button.
  5. In the "System Properties" window, select the "Advanced" tab.
  6. Click the Environment Variables button.
    An "Environment Variables" dialog will open.
  7. Select the "Path" variable from under the "System variables" section of the dialog "Environment Variables" dialog.
    An "Edit environment variable" dialog will open.
  8. Click the New button in the "Edit environment variable" dialog.
  9. Type %SystemRoot%\system32
  10. Click the OK button in the "Edit environment variable" dialog.
  11. Click the OK button in the "Environment Variables" dialog.
  12. Restart Arduino IDE if it is running.

Now try compiling or uploading to your ESP32 board again. Hopefully the error will no longer occur.


Please let me know if you have any questions or problems while following those instructions.

4 Likes

Thank you for your timely reply.
I did try copying my sketch to a folder in another drive and running it from there - you were right, it gave me the same error when verifying, so my own workaround was limited as you thought it would be.

I have followed your suggestion (I have Windows 7) to the letter and tried running the same copied sketch again - it didn't fix the problem...
UNTIL I checked the path carefully once again: the issue was that I had a few values already there, and they were separated by a semicolon (;), which I did place before adding the path value you suggested, however, my mistake was that I had also pasted a SPACE along with the value I copied from your answer, right after the semicolon and before the value - that was enough to make it not work.
Once I had removed the space and pressed OK to confirm the change, I tried running the same sketch from another drive and it worked! :grinning:

So, this is a lesson for everyone else reading this to pay attention to details like an empty space between values inside a variable.
Below are the values I currently have in my PATH (after adding your suggestion):
C:\Program Files\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ffmpeg\bin;C:\Program Files (x86)\Codebox\BitMeterOS;%SystemRoot%\system32

As it can be seen, spaces are allowed inside the values themselves, but not between the values - only a semicolon goes there with no space. YOU know this, of course, but I didn't know it and now I'm letting others know it as well.
That's the wonders of sharing the knowledge.

Thank you again for your very helpful answer, I am glad we have such knowledgeable people ready to help.

You are welcome. Great job on spotting the problem in your Path variable! Thanks for taking the time to post an update with your solution.

Regards,
Per

1 Like

I'm also having this issue but I'm on a Mac, anyone know how to fix it?

Hi @mike0xlong420. I'm going to ask you to post the full output from a compilation.


:exclamation: This procedure is not intended to solve the problem. The purpose is to gather more information.


Please do this:

  1. Compile the sketch, just as you did before when you encountered the issue.
  2. Wait for the compilation to fail.
  3. You will see a "Compilation error: ..." notification at the bottom right corner of the Arduino IDE window. Click the "COPY ERROR MESSAGES" button on that notification.
  4. Open a forum reply here by clicking the "Reply" button.
  5. Click the <CODE/> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
    Code block icon on toolbar
  6. Press the Command+V keyboard shortcut.
    This will paste the compilation output into the code block.
  7. Move the cursor outside of the code block markup before you add any additional text to your reply.
  8. Click the "Reply" button to post the output.

In case the output is longer than the forum software will allow to be added to a post, you can instead save it to a .txt file and then attach that file to a reply here:

  1. Open any text editor program.
  2. Paste the copied output into the text editor.
  3. Save the file in .txt format.
  4. Open a forum reply here by clicking the "Reply" button.
  5. Click the "Upload" icon (Upload icon) on the post composer toolbar:
    Upload icon on toolbar
    The "Open" dialog will open.
  6. Select the .txt file you saved from the "Open" dialog.
  7. Click the "Open" button.
    The dialog will close.
  8. Click the "Reply" button to publish the post.

Alternatively, instead of using the "Upload" icon on the post composer toolbar as described in steps (5) - (7) above, you can simply drag and drop the .txt file onto the post composer field to attach it.

Hello,

I am having the same issue. I have included "%SystemRoot%\system32" in my environment variables but the error persists. Can you advise what to do next please?

My error log is as follows (I am using Arduino IDE 2.3.2):


FQBN: esp32:esp32:esp32da
Using board 'esp32da' from platform in folder: C:\Users\PC\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.17
Using core 'esp32' from platform in folder: C:\Users\PC\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.17

cmd /c if exist "C:\\Users\\PC\\OneDrive\\Desktop\\ESP32-LoRa SX1276 za badzu\\esp32-SX1276_interface\\partitions.csv" COPY /y "C:\\Users\\PC\\OneDrive\\Desktop\\ESP32-LoRa SX1276 za badzu\\esp32-SX1276_interface\\partitions.csv" "C:\\Users\\PC\\AppData\\Local\\Temp\\arduino\\sketches\\EA3B4BCFFD1CD9C3F94CA00ED38EA46B\\partitions.csv"
exec: "cmd": executable file not found in %PATH%

Compilation error: exec: "cmd": executable file not found in %PATH%

Thanks

A small update, I have resolved my issue with ESP32 boards by including a "%SystemRoot%\system32" into "PATH" variable of the System environmental variable. Maybe it is something which was being said in previous answers but I haven't fully understood it. :slight_smile:
Cheers!

1 Like

You had probably made the same mistake as I had, namely you had included a space between variables, while there should be no space around the ; separator.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.