Sunday, 1 December 2019

windows 7 - How to force short name (8dot3) generation?


I have a problem with windows windows shortnames. Sometimes the short names do not seem to be generated for "Program Files" and "Program Files (x86)".


I verified that short name generation is enabled with fsutil behavior query disable8dot3 C: which tells me that the system wide setting is 2 (per volume) and the local value is 0 (create 8dot3 names).


It should look roughly like this (note that is is a german 32bit copy):


C:\>dir /a /x

Verzeichnis von C:\

21.12.2011 00:17
$Recycle.Bin
14.07.2009 05:53 DOCUME~1 Documents and Settings [C:\Users]
09.01.2011 15:35 DOKUME~1 Dokumente und Einstellungen [C:Users]
27.11.2013 15:11 2.147.016.704 pagefile.sys
14.07.2009 03:37
PerfLogs
26.11.2013 17:31
PROGRA~1 Program Files
08.11.2013 21:58
PROGRA~2 ProgramData
09.01.2011 15:35 PROGRA~3 Programme [C:\Program Files]
09.01.2011 15:35
Recovery
26.11.2013 17:40
SYSTEM~1 System Volume Information
23.01.2011 15:00
Temp
11.01.2011 20:56
Users
08.11.2013 14:53 Windows

However on another machine (64bit copy), this looks like C:>dir /a /x


 Verzeichnis von C:\

21.12.2011 00:17
$Recycle.Bin
14.07.2009 05:53 DOCUME~1 Documents and Settings [C:\Users]
09.01.2011 15:35 DOKUME~1 Dokumente und Einstellungen [C:Users]
27.11.2013 15:11 2.147.016.704 pagefile.sys
14.07.2009 03:37
PerfLogs
26.11.2013 17:31
Program Files
26.11.2013 17:31
Program Files (x86)
08.11.2013 21:58
ProgramData
09.01.2011 15:35
Recovery
26.11.2013 17:40
SYSTEM~1 System Volume Information
23.01.2011 15:00
Temp
11.01.2011 20:56 Users
08.11.2013 14:53 Windows

As you might have noticed, the short names are missing for the program folders.


The question is now how to generate them, because I need those short names for a few older scripts. I tried with fsutil file setshortname "Program Files" "PROGRA~1", but this just gives me Access denied..



Answer



Like i said in my comment... The only way i know how Windows is going to re-generate the short-name is to copy the directory and delete the original. (not doable for the "Program Files" directory.)


It would be best to change the script to use long file- and folder-names. If the script uses PROGRA~1 it will get in trouble with installations where the drive was cloned in a way the directories where copied back. For example if ProgramData is copied first onto the disk it will be named PROGRA~1 and Program Files will be named PROGRA~2.


There is an option to keep the scripts working for now:


You could create a directory-junction from PROGRA~1 to C:\Program Files. That way the scripts keep working and you have time to change them.


mklink /J "C:\PROGRA~1" "C:\Program Files"

Output of mklink /?:


Creates a symbolic link.

MKLINK [[/D] | [/H] | [/J]] Link Target

/D Creates a directory symbolic link. Default is a file
symbolic link.
/H Creates a hard link instead of a symbolic link.
/J Creates a Directory Junction.
Link specifies the new symbolic link name.
Target specifies the path (relative or absolute) that the new link
refers to.

No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...