How windows resolve short names (8.3) to full names

I have a computer with a 64-bit version of Windows Server 2003. There is a Java application that uses the cmd file as a launch. Launcher does it

SET JAVA_HOME= C:\Progra~1\Java "%JAVA_HOME%\bin\java" [java program execution line] 

Java is installed in C: \ Program Files \ Java. Since these are x64 windows, it also has a C: \ Program Files (x86) \ folder.

Now the actual problem is that from time to time this application does not start, because it does not find java.

So the question is, what windows do to eliminate such ambiguity? Based on the fact that he makes decisions about which folder to choose?

+4
source share
4 answers

The simple answer: Windows stores both short and long file names.

This happened when vfat (on top of FAT16) was introduced with Windows 95, continued in FAT32 and still around in NTFS:

When saving a file with a long file, the name for the NTFS drive, NTFS creates, by default, a second file directory entry with a short file name in accordance with 8.3.

(You can disable 8.3 names on NTFS ).

Side note. You can see what short file names are in the cmd.exe window by running dir /x (thanks cHao for pointing this out).

+1
source

The relationship between long and short names is created when the directory is created. Windows creates a "short path entry" in the directory that contains the name 8.3. Thus, the relationship between the short and long name is constant and does not change if you do not change directories (rename, delete, recreate).

This is an example of my car (windows 7)

 C:\>mkdir temp C:\>cd temp C:\temp>dir El volumen de la unidad C no tiene etiqueta. El número de serie del volumen es: 0A74-FE30 Directorio de C:\temp 24/05/2010 12:14 pm <DIR> . 24/05/2010 12:14 pm <DIR> .. 0 archivos 0 bytes 2 dirs 6.090.723.328 bytes libres C:\temp>mkdir "Program Files" C:\temp>mkdir "Program Files (x86)" C:\temp>mkdir "Program Files (x86_64)" C:\temp>dir /x El volumen de la unidad C no tiene etiqueta. El número de serie del volumen es: 0A74-FE30 Directorio de C:\temp 24/05/2010 12:15 pm <DIR> . 24/05/2010 12:15 pm <DIR> .. 24/05/2010 12:14 pm <DIR> PROGRA~1 Program Files 24/05/2010 12:14 pm <DIR> PROGRA~2 Program Files (x86) 24/05/2010 12:15 pm <DIR> PROGRA~3 Program Files (x86_64) 0 archivos 0 bytes 5 dirs 6.090.723.328 bytes libres C:\temp>rmdir "Program Files" C:\temp>mkdir "Program Files (new)" C:\temp>dir /x El volumen de la unidad C no tiene etiqueta. El número de serie del volumen es: 0A74-FE30 Directorio de C:\temp 24/05/2010 12:15 pm <DIR> . 24/05/2010 12:15 pm <DIR> .. 24/05/2010 12:15 pm <DIR> PROGRA~1 Program Files (new) 24/05/2010 12:14 pm <DIR> PROGRA~2 Program Files (x86) 24/05/2010 12:15 pm <DIR> PROGRA~3 Program Files (x86_64) 0 archivos 0 bytes 5 dirs 6.090.723.328 bytes libres C:\temp>rmdir "Program Files (x86)" C:\temp>dir /x El volumen de la unidad C no tiene etiqueta. El número de serie del volumen es: 0A74-FE30 Directorio de C:\temp 24/05/2010 12:15 pm <DIR> . 24/05/2010 12:15 pm <DIR> .. 24/05/2010 12:15 pm <DIR> PROGRA~1 Program Files (new) 24/05/2010 12:15 pm <DIR> PROGRA~3 Program Files (x86_64) 0 archivos 0 bytes 4 dirs 6.090.723.328 bytes libres 

As you can see, the name PROGRA ~ 1 is "reused" when deleting the source directory and creating a new one with a name that, when abbreviated, corresponds to the PROGRA prefix.

Hth

+1
source

Details of gory (patent infestations) are also described on this Wikipedia page .

0
source

Whenever a file is created in the NTFS file system, the OS can (and, as a rule, before Windows 7/2008) also create a short name for it. This is not required, and the name may actually be anything, but if the regular name is not yet 8.3, the short name is usually the first 6-character character of the file name, tilde (~) and digit (1 for the first file with the same first characters, 2 for the second, etc.), a period and the first 3 letters of the extension. (If there is no extension, then usually there is no point.)

The number does not apply to the file name otherwise, which means that the "program files" can become "progra ~ 1" or "progra ~ 2" or "progr ~ 50", depending on which other files / directories are in the same the place is called and (mainly) when they were made. But once the name is set, it rarely changes unless the file is renamed.

0
source

Source: https://habr.com/ru/post/1310743/


All Articles