The Computer Oracle

How to force short name (8dot3) generation?

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Life in a Drop

--

Chapters
00:00 How To Force Short Name (8dot3) Generation?
01:37 Accepted Answer Score 6
02:38 Answer 2 Score 10
03:12 Thank you

--

Full question
https://superuser.com/questions/681330/h...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#windows7 #commandline #cmdexe

#avk47



ANSWER 1

Score 10


To define shortnames (8dot3) for Program files do the following:

  1. Restart computer
  2. upon boot start in safemode with cmd prompt (F8 on my computer)
  3. Log in
  4. from cmd prompt enter the following cmds

    fsutil 8dot3name query
    fsutil behavior set disable8dot3 0
    fsutil file setshortname "Program Files" PROGRA~1
    dir /X
    

You should now see the shortname defined for program files. If you'd like, set the 8dot3name behavior back to the original setting which was returned by the query cmd.




ACCEPTED ANSWER

Score 6


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.