2

What would cause an EXE extension to be mandatory at the command line and how can it be resolved in the current shell?

I had a path that was long. > 2048 characters, and I installed a program, nodejs that added to that path. And then things went a bit screwy. I had a problem that some people seem to get at some point when their path is > 2048 char. The bulk of my path got removed. (I still have some old cmd shells with my path so that's not a big problem so i've saved my old path in a file) And the windir environment variable got (I think set to nothing), in the registry. And I couldn't even open the environment variables window (this is a symptom people can get when their path is > 2048 char and they lose their windir variable). So I used setx to create windir=c:\windows and I opened the environment variables window and fixed my PATH to what it was. And now cmd prompt windows that I open are fine.

But I still have some older cmd prompt windows from prior to me fixing it, and I understand the path is shortened in them, and I understand there's no windir variable set, but I still see a bizarre result in them that I cannot explain. And that i'd like to be able to fix from within those cmd windows.

It seems that I need to put the EXE after an executable in order to run it.

C:\crp>path
PATH=C:\Ruby21\bin;C:\Program Files (x86)\IDM Computer Solutions\UltraEdit\;C:\Program Files (x86)\IDM Computer Solutions\UltraCompare\;C:\Program Files (x86)\Nmap;C:\Program Files (x86)\smartmontools\bin;C:\ProgramData\chocolatey\bin;C:\Users\user\AppData
\Roaming\npm

C:\crp>cd \windows\system32

C:\Windows\System32>ping
'ping' is not recognized as an internal or external command,
operable program or batch file.

C:\Windows\System32>ping.exe

Usage: ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS]
......


C:\Windows\System32>set path=

C:\Windows\System32>ping.exe

Usage: ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS]
.....

C:\Windows\System32>ping
'ping' is not recognized as an internal or external command,
operable program or batch file.

C:\Windows\System32>

and

C:\Windows\System32>ping
'ping' is not recognized as an internal or external command,
operable program or batch file.

C:\Windows\System32>set windir=c:\windows

C:\Windows\System32>echo %windir%
c:\windows

C:\Windows\System32>ping
'ping' is not recognized as an internal or external command,
operable program or batch file.

C:\Windows\System32>ping.exe

Usage: ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS]

The funny thing is that I think what solved it for future cmd prompts was setting windir permanently, i.e. with setx (then ( went to environemnt variables window and fixed the path).

I could fix the path within a busted cmd session, I can even fix windir in that cmd session, I know doing neither should help but it's making putting EXE at the end of filenames mandatory. So I don't see the cause.. or how to fix it for a particular cmd session.

New cmd windows are fine.. But for the sake of understand what is going on, I want to be able to fix it from within a busted cmd session. And if not, then i'd like to know why it can't be fixed within it.

Added

Relevant to Dmitry's post

C:\Windows\System32>echo %PATHEXT%
%PATHEXT%;.RB;.RBW

Indeed, I see .EXE is not listed, and a bit odd that literal %PATHEXT% is listed in there. Seems almost infinitely recursive(if DOS were to even handle recursion / recursion there, which it wouldn't)!

5

Did you check PATHEXT environment variable? It lists extensions, considered executable. Mine is like this:

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

BTW, there's nice environment editor: Rapid Environment Editor

|improve this answer|||||
  • 1
    That was it. PATHEXT didn't have .EXE listed there. And it was even corrupted into having literal %PATHEXT% in there. That must have somehow fixed itself for later cmd prompts, during the process after when I did setx to set windir, and was then able to get the properties environment variables window open and added the path variable in propertly and hit OK. – barlop Sep 16 '15 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.