Environment Variables: Short vs Long Pathnames? - "DOCUME~1" vs."Documents and Settings"

  • Thread starter Thread starter Martin B.
  • Start date Start date
M

Martin B.

Hello.

*** Is there a setting that tells Windows how/if/when it should expand
environment variables to long vs. short pathnames? ***

I have two Windows XP boxes. (german, service pack 2)

On both machines the settings for the environment variable %TEMP% are
the same, that is:
HKEY_CURRENT_USER\Environment -
TEMP [REG_EXPAND_SZ] = %USERPROFILE%\Lokale Einstellungen\Temp

One one box resolving %TEMP% will yield the short pathname and on the
other box I'll get the long pathname. (Note that %USERPROFILE% will
yield the long path on both boxes

PC1:
C:\>echo %USERPROFILE%
C:\Dokumente und Einstellungen\Trappel

C:\>echo %TEMP%
C:\DOKUME~1\Trappel\LOKALE~1\Temp


PC2:
C:\>echo %USERPROFILE%
C:\Dokumente und Einstellungen\hammer

C:\>echo %TEMP%
C:\Dokumente und Einstellungen\hammer\Lokale Einstellungen\Temp

C:\>cd C:\DOKUME~1
C:\DOKUME~1> REM ... note here that the short pathname does exists

Opening %TEMP% via Start > Run ... will yield the same different
pathnames in the title bar of the new explorer windows so I'm *guessing*
it's not a cmd.exe issue but some explorer policy.

*** Does anyone know which setting in windows controls this different
behaviour? ***

Add Info:
---------
Under
"My Computer" -> Properties -> Advanced Tab -> Environment Variables
the following is set:
* System: TEMP = "%SystemRoot%\TEMP" (this appears to be the Windows
default) -- %SystemRoot% expands to C:\WINDOWS
* User: TEMP = "%USERPROFILE%\Lokale Einstellungen\Temp"


cheers,
Martin
 
The Short File Name Generation (NtfsDisable8dot3NameCreation) is most
likely disabled on the first machine but not on the second one. The
system automatically converts the Temp and Tmp variables to short
filenames unless Short Filename Generation is disabled.

http://blogs.msdn.com/oldnewthing/archive/2004/12/24/331750.aspx
The Old New Thing : Why does the system convert TEMP to a short file name?

John
 
John said:
The Short File Name Generation (NtfsDisable8dot3NameCreation) is most
likely disabled on the first machine but not on the second one. The
system automatically converts the Temp and Tmp variables to short
filenames unless Short Filename Generation is disabled.

I checked that!
See below where I write:
[q]
PC2 ...[/q]

Or can you change into a shortname directory even if there is no shortname??

cheers,
Martin

http://blogs.msdn.com/oldnewthing/archive/2004/12/24/331750.aspx
The Old New Thing : Why does the system convert TEMP to a short file name?

John
Hello.

*** Is there a setting that tells Windows how/if/when it should expand
environment variables to long vs. short pathnames? ***

I have two Windows XP boxes. (german, service pack 2)

On both machines the settings for the environment variable %TEMP% are
the same, that is:
HKEY_CURRENT_USER\Environment -
TEMP [REG_EXPAND_SZ] = %USERPROFILE%\Lokale Einstellungen\Temp

One one box resolving %TEMP% will yield the short pathname and on the
other box I'll get the long pathname. (Note that %USERPROFILE% will
yield the long path on both boxes

PC1:
C:\>echo %USERPROFILE%
C:\Dokumente und Einstellungen\Trappel

C:\>echo %TEMP%
C:\DOKUME~1\Trappel\LOKALE~1\Temp


PC2:
C:\>echo %USERPROFILE%
C:\Dokumente und Einstellungen\hammer

C:\>echo %TEMP%
C:\Dokumente und Einstellungen\hammer\Lokale Einstellungen\Temp

C:\>cd C:\DOKUME~1
C:\DOKUME~1> REM ... note here that the short pathname does exists

Opening %TEMP% via Start > Run ... will yield the same different
pathnames in the title bar of the new explorer windows so I'm *guessing*
it's not a cmd.exe issue but some explorer policy.

*** Does anyone know which setting in windows controls this different
behaviour? ***

Add Info:
---------
Under
"My Computer" -> Properties -> Advanced Tab -> Environment Variables
the following is set:
* System: TEMP = "%SystemRoot%\TEMP" (this appears to be the Windows
default) -- %SystemRoot% expands to C:\WINDOWS
* User: TEMP = "%USERPROFILE%\Lokale Einstellungen\Temp"


cheers,
Martin
 
Martin said:
John said:
The Short File Name Generation (NtfsDisable8dot3NameCreation) is most
likely disabled on the first machine but not on the second one. The
system automatically converts the Temp and Tmp variables to short
filenames unless Short Filename Generation is disabled.

I checked that!
See below where I write:
[q]
PC2 ...[/q]

Or can you change into a shortname directory even if there is no
shortname??

It's because of the manner in which Short File Names are generated or
created.

If
HKLM\CurrentControlSet\Control\FileSystem\NtfsDisable8dot3NameCreation
is set to 0 SFN are generated when files or folders are created, if the
value is set to 1 SFN are not generated.

The SFN is only generated when the file or folder is created, if you
change the NtfsDisable8dot3NameCreation value from 1 to 0 after the fact
the file system will not generate SFN for files or folders that already
exist and that were create when SFN creation was disabled, it will only
generate SFN for new objects that you create.

If the NtfsDisable8dot3NameCreation is set to 0 the system will generate
SFN for objects that you create and it will store the SFN in the MFT.
If you then change the value to 1 the file system will not remove SFN
that were created while SFN creation was enabled, the SFN will remain
stored in the MFT.

You can test this by toggling the NtfsDisable8dot3NameCreation value
back and forth between 0 and 1 and do some tests. Please note that this
is a system setting that requires a reboot for changes to apply.

Set the value to 0 then create a new user with a "Long User Name" and
then see how the system creates the Temp/Tmp variables. Then change the
value to 1 and create a second new user with a long name and note the
difference. You can also test this by simply toggling the
NtfsDisable8dot3NameCreation value and then create a new folder with a
long name in "Dokumente und Einstellungen\hammer\Lokale Einstellungen\"
and then change the variable to point to the new folder with a long name
and you will see how the system handles this depending on how the
NtfsDisable8dot3NameCreation value is set. Remember that for changes to
apply you must reboot when you change this value.

John
 
Back
Top