Andy
Andy

Reputation: 103

'C:\Program' is not recognized error

I set ANT_HOME=C:\Program Files\ant-1.8.0 then try to build local host by Weblogic.
But, it gives me the following error:

C:\Program' is not recognized as an internal or external command.

I already tried putting quotes when defining the variable: "ANT_HOME=C:\Program Files\ant-1.8.0". but it is not working either, it shows the following error message:

Files\ant-1.8.0""=="" was unexpected at this time.

I have been stuck here for the past few weeks. Iv'e googled it many times but I still cant resolve the problem.

Edited:

dir c:\pro /x

didn't show the Progra~1 and Progra~2

Upvotes: 1

Views: 499

Answers (2)

Marged
Marged

Reputation: 10973

Even current versions of Windows automatically create a second file name which adheres to the old 8.3 naming scheme which has been there since DOS was invented. This name does not contain a space character which makes it a good candidate to be used in scenarios like that described by you.

Unless this has been explicitly disabled you can show the alternative filenames. Open a dosbox and enter dir C:\pro* /x. The result will be similar to this:

Windows 10 showing short filenames

I ran this on a German Windows 10 Pro but the output will be identical on other versions of Windows. You can see that for C:\Program Files Windows created an alternative name C:\Progra~1.

Upvotes: 0

Stephan
Stephan

Reputation: 56238

set "var=content" is a good practice to avoid having unintended trailing spaces, but your error occures when using the value. There you need qoutes (that are not part of your variable content with the above syntax):

set "folder=c:\program Files"
dir %folder%
dir "%folder%"

the first dir will give you "file not found", because it tries to show you the contents of c:\program (which doesn't exist) plus the contents of files (which also doesn't exist). The second dir will show you successfully the contents of "c:\program files"

Upvotes: 1

Related Questions