# PATHEXT environment variable not working

I want to use gcc on Windows, so someone gave me a MinGW folder. I put the D:\software\MinGW\bin\ folder in my PATH. But when I open a new CMD and type gcc, I get

'gcc' is not recognized as an internal or external command, operable program or batch file

However, when I type gcc.exe, it works.

So I read on this post that this may be related to my PATHEXT variable. However, I changed my PATHEXT system variable so that it matches exactly what is said in the answer, and I removed my PATHEXT user variable, but it didn't change anything, I still have to write gcc.exe instead of gcc.

The strange thing is, other programs like Java work without writing the .exe extension. It seems like this problem only impacts the executables inside the D:\software\MinGW\bin\ folder.

D:\> set PATH


Path=D:\software\MinGW\bin;C:\Program Files\Python39\Scripts;C:\Program Files\Python39;D:\software\Perl64\bin;C:\Users\Jacopo\AppData\Roaming\ActiveState\bin;D:\software\VMWare\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS Client;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;D:\software\Node;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Program Files\Microsoft VS Code\bin;C:\xampp\php;C:\ProgramData\ComposerSetup\bin;D:\software\doxygen\bin;C:\xampp\mysql\bin;C:\Program Files (x86)\Gpg4win..\GnuPG\bin;D:\software\Git\cmd;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit;D:\software\MiKTeX\miktex\bin\x64;D:\software\OpenSSL-Win64\bin;D:\software\Nmap;D:\software\Aliases;D:\software\MinGW\bin;D:\software\Ruby27-x64\bin;C:\Program Files\Java\jdk1.8.0_112\bin;C:\Program Files (x86)\Google\Chrome\Application;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS Client;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;D:\software\Git\cmd;D:\software\Node;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Program Files\Java\jdk1.8.0_112\bin;C:\Program Files (x86)\Common Files\Oracle\Java;D:\software\Qt\Tools\mingw530_32\bin;D:\software\Qt\5.9.8\winrt_x86_msvc2917\bin;C:\Users\Jacopo\AppData\Roaming\Composer\vendor\bin;D:\software\Docker Toolbox;D:\software\Nmap;

PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

What did I do wrong?

• Please edit your question and include the current contents of your PATH variable within the body of your question. You need to attempt running the command within a MinGW prompt. While it is possible to run gcc without MinGW your system isn't configured to do that (i.e. WSL). Jan 21, 2021 at 14:52
• @Ramhound Done. Jan 21, 2021 at 14:55
• I also had the same problem, and I fixed it by simply making all the extensions lowercase (though I don't know why that worked, I though Windows was case-insensitive). May 13, 2021 at 17:58
• This could happen if you have set the drive to be case-sensitive Jun 6, 2021 at 4:51
• You can check this by running command fsutil.exe file queryCaseSensitiveInfo C:\path\to\dir Jun 6, 2021 at 5:10

The one explanation I can come up with for this behavior is that you have a file or folder in the MinGW\bin folder that is named gcc.

This would require to add .exe to avoid using that file.

Check for the existence of gcc in MinGW\bin or any of its sub-folders.

• There is no such file in the folder, but would it be possible that the error was caused by a gcc file in another folder of the Path? In doubt, I removed D:\software\Qt\Tools\mingw530_32\bin and D:\software\Qt\5.9.8\winrt_x86_msvc2917\bin from my Path but nothing changed. I should add that on Powershell it works without specifying the .exe. Jan 21, 2021 at 22:18
• A fast check is in CMD to set PATHEXT=.EXE and try. Jan 21, 2021 at 22:30
• No, nothing changed unfortunately. Jan 21, 2021 at 22:46
• Check both versions of PATHEXT - user and system. One might be overriding the other. Jan 21, 2021 at 23:04
• I deleted the user PATHEXT. The one you see at the end of the set PATH result is the system one Jan 22, 2021 at 6:22

I fixed my problem by copying my MinGW folder from the D:\ drive to the Program File folder on the C:\ drive. I changed the Path variable accordingly, and it worked. Still no idea why it didn't work with the D:\software folder.