Server 2008 won’t run executables from CMD prompt without .exe extension

windows-server-2008

On one of our production server 2008 boxes, I cannot run executables from a CMD prompt without supplying the full filename, including the '.exe' extension. For example, when running "java" produced the usual "is not recognized as an internal or external command" message, I assumed I had borked the path and/or java_home variables. However, even navigating to the %java_home%\bin directory and typing "java" produced the same error. If I type "java.exe" instead, all works perfectly.

The problem does not only affect java.exe. Even Microsoft executables suffer the same problem — ping fails, ping.exe works; ipconfig fails, ipconfig.exe works; manually created batch file 'test' only works when invoked explicitly as 'test.bat'.

Any bright ideas?

[edit]
Awesome! The issue was a bad value in pathext — someone had inadvertantly edited the PATHEXT system variable (prepending %java_home%\bin), when that edit should have been on the PATH variable.

Thanks!

Best Answer

OK, I'm going to chuck my hat in the ring and say your PATHEXT System Variable is hosed or non-existent on that system. Look closely in your environment variables for a duplicate PATHEXT entry too.

The default value of the PATHEXT System Variable should be:

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

The bad news is that if the server booted up without this, you'll probably need to reboot to get the setting to take effect since it's a System Variable.

Did you remove a program from that box recently?

As per: http://vlaurie.com/computers2/Articles/environment.htm

The %PATHEXT% environment variable contains executable file extensions that do not have to be specified for any file in a directory given in the %PATH% variable. The extension .EXE is the most common. Thus the filename sol.exe need only be entered as sol in a command line. If files have the same name but different extensions, the operating system searches in the following order of precedence: .EXE, .COM, .BAT, and .CMD.

Related Topic