Installing Windows 10/11 without 8.3 file names

Long file names first appeared in Windows 95, more than 20 years ago. Despite this, Windows 10 and Windows 11 are still installed with 8.3 file names enabled by default. For example, after a clean install of Windows 10 Home, there are almost 50,000 8.3 file names present on C:\, including the notorious PROGRA~1:

Microsoft Windows [Version 10.0.17763.379]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\>dir c:\ /a /x
 Volume in drive C has no label.
 Volume Serial Number is 72AF-6CDE

 Directory of c:\

2019-09-11  06:59    <DIR>                       $Recycle.Bin
2019-09-11  16:55    <DIR>                       Boot
2019-09-11  06:58    <JUNCTION>     DOCUME~1     Documents and Settings [C:\Users]
2018-09-15  07:10    <DIR>                       PerfLogs
2019-09-11  06:58    <DIR>          PROGRA~1     Program Files
2019-09-11  07:15    <DIR>          PROGRA~2     ProgramData
2019-09-11  06:57    <DIR>                       Recovery
2019-09-11  07:08    <DIR>          SYSTEM~1     System Volume Information
2019-09-11  07:15    <DIR>                       Users
2019-09-11  06:58    <DIR>                       Windows
2018-09-15  07:08                24              autoexec.bat
2019-03-12  08:12           408.364              bootmgr
2018-09-15  07:06                 1              BOOTNXT
2019-09-11  16:55             8.192              BOOTSECT.BAK
2018-09-15  07:08                10              config.sys
2019-09-11  06:58     1.342.177.280              pagefile.sys
2019-09-11  06:58       268.435.456              swapfile.sys
               8 File(s)  1.611.031.129 bytes
              10 Dir(s)  46.976.679.936 bytes free

8.3 file names cause several problems:

While %windir%\system32\fsutil.exe 8dot3name strip can be used to strip existing 8.3 file names from a volume at any time, it is preferable to turn off 8.3 file name creation as early as possible. Otherwise, 8.3 file names will inevitably accumulate in the registry.

Method 1: Stripping 8.3 file names during Windows setup

  1. Boot from an installation media (Windows DVD, USB stick, PXE) and press Shift+F10 to open a command prompt as soon as you see the language and keyboard selection dialog. Then run the command setup.exe /noreboot and proceed as usual. Windows setup copies the files onto the selected partition and installs the boot manager, but does not reboot the computer.
  2. When the command prompt shows again, use diskpart to determine the volume that Windows is being installed to. Here, D: is the relevant volume:
    X:\Sources>diskpart
    
    Microsoft DiskPart version 10.0.18362.1
    
    Copyright (C) Microsoft Corporation.
    On computer: MINWINPC
    
    DISKPART> list vol
    
      Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
      ----------  ---  -----------  -----  ----------  -------  ---------  --------
      Volume 0     E   CCCOMA_X86F  UDF    CD-ROM      3461 MB  Healthy
      Volume 1     C   System Rese  NTFS   Partition    549 MB  Healthy
      Volume 2     D                NTFS   Partition     49 GB  Healthy
    
    DISKPART> exit
    
    Leaving DiskPart...
  3. Disable the creation of 8.3 file names on that volume:
    X:\Sources>fsutil 8dot3name set d: 1
    Successfully disabled 8dot3name generation on d:
  4. Remove all already created 8.3 file names:
    X:\Sources>fsutil 8dot3name strip /s /f d:\
    Scanning registry...
    
    Total affected registry keys:                   0
    
    Stripping 8dot3 names...
    
    Total files and directories scanned:        80517
    Total 8dot3 names found:                    47135
    Total 8dot3 names stripped:                 47135
    
    For details on the operations performed please see the log:
    "X:\windows\TEMP\8dot3_removal_log @(GMT 2019-02-01 01-50-41).log"
  5. Run wpeutil.exe reboot to reboot the computer and start the second phase of Windows setup.

Method 2: Stripping 8.3 file names from install.wim

For whatever reason, the Windows 10 and Windows 11 WIM images (boot.wim and install.wim) contain 8.3 file names. This can be demonstrated e.g. using 7-Zip:

C:\>"%ProgramFiles%\7-Zip\7z.exe" l -slt "install.wim" | findstr.exe /r /c:"^Short Name = [A-Z]"
Short Name = PROGRA~1
Short Name = PROGRA~2
Short Name = COMMON~1
Short Name = INTERN~1
Short Name = WINDOW~1
Short Name = WINDOW~2
Short Name = WI54FB~1
Short Name = WI7A8C~1
…

It turns out that Windows is installed with 8.3 file names exactly because the install.wim contains 8.3 file names. Therefore, if you strip all 8.3 file names from the install.wim, Windows will be installed without them.

  1. Download a Windows 10 or Windows 11 ISO image.
  2. Extract the ISO image.
  3. Locate the install.wim file in the sources subfolder.
  4. Download a copy of PsExec.exe as fsutil.exe must be executed in the SYSTEM account.
  5. Open a PowerShell session with Administrator privileges and run this PowerShell code:
    function Remove-WimShortNames {
        [CmdletBinding()]
        param(
            [Parameter( Mandatory )]
            [string]
            $WimFile,
    
            [string]
            $MountDirectory = 'C:\mnt',
    
            [ValidateSet( 'Errors', 'Warnings', 'WarningsInfo' )]
            [string]
            $LogLevel = 'Errors',
    
            [string]
            $PsExecPath = "$env:ProgramFiles\SysinternalsSuite\PsExec.exe"
        );
    
        if( -not [System.IO.File]::Exists( $WimFile ) ) {
            throw "File '$WimFile' does not exist.";
        }
    
        if( -not [System.IO.File]::Exists( $PsExecPath ) ) {
            throw "File '$PsExecPath' does not exist.";
        }
    
        $params = @{
            LogLevel = $LogLevel;
        };
    
        mkdir -Path $MountDirectory -ErrorAction 'SilentlyContinue' | Out-Null;
        Get-WindowsImage -ImagePath $WimFile @params | ForEach-Object -Process {
            "Now processing edition '{0}'. Mounting to '{1}'." -f $_.ImageName, $MountDirectory | Write-Host;
            Mount-WindowsImage -Path $MountDirectory -ImagePath $WimFile -Name $_.ImageName @params;
            & $PsExecPath -s "$env:windir\system32\fsutil.exe" 8dot3name strip /f /s $MountDirectory;
            if( $LASTEXITCODE ) {
                throw "fsutil.exe exited with error code $LASTEXITCODE.";
            }
            Dismount-WindowsImage -Path $MountDirectory -Save @params;
        };
        Remove-Item -LiteralPath $MountDirectory -Force;
    }
    Remove-WimShortNames.ps1
  6. Call the function with the path of the .wim file:
    Remove-WimShortNames -WimFile 'C:\iso\sources\install.wim';
    This script will run for serveral minutes as it mounts the editions contained in install.wim (such as Home or Education) one after another. Use a mount directory with a path as short as possible, such as C:\mnt. Otherwise, the resulting file paths might become too long.
  7. Copy the extracted ISO image (which now includes the modified install.wim) to a bootable USB stick, or use software such as ImgBurn to create a bootable DVD or a bootable ISO image.
  8. Install Windows.
    1. If you let the Setup program format your hard drive, no further action is required.
    2. If you want to re-use an existing volume without formatting it, you need to disable 8.3 file name generation manually. When the Where do you want to install Windows? dialog is shown, press Shift+F10, then type:
      fsutil 8dot3name set c: 1
      The command should respond with the message Successfully disabled 8dot3name generation on c:. Then type exit to continue the installation:

Conclusion

After Windows has been installed, make sure that dir c:\ /a /x does not show any 8.3 file names and that %windir%\system32\fsutil.exe 8dot3name query c: reports 8.3 file name are not generated.

Note that the /f parameter of fsutil is safe to use since the registry hive files contained in install.wim, such as \windows\system32\Config\SYSTEM or \Users\Default\NTUSER.DAT, do not reference any 8.3 file names.