GetTempFileNameW: The directory name is invalid

Symptoms

When trying to install an application on Windows/Windows Server by clicking the setup executable (e.g. setup.exe) you receive an Installer error:

0x8007010b - GetTempFileNameW: The directory name is invalid.

Most likely you are logged in remotely to the Windows (Server) desktop via a Remote Desktop Connection .

Cause

When connecting to a Windows (Server) desktop via Remote Desktop, a subdirectory with a Session ID is added to the temporary folder path. This subdirectory doesn't exist and causes the executable to fail with the message 0x8007010b - GetTempFileNameW: The directory name is invalid. .

Resolution

Solution 1:

  1. Find out what your current temporary folder path is by opening commandprompt and typing: echo %TMP%
    A possible output could be: C:\Users\<user>\AppData\Local\Temp\2.
    Notice the number 2 at the end of the path. This is your Session ID.
  2. Navigate to the folder: C:\Users\<user>\AppData\Local\Temp
  3. Create the missing folder. (In our case the folder was called: "2".)
  4. Try to run the executable installer again. If all went fine the installation should work.

Solution 2:

  1. Run gpedit.msc to open the Local Group Policy Editor.
  2. Navigate to:
    Windows Server 2003+: Computer Configuration\Administrative Templates\Windows Components\Terminal Services\Temporary folders
    Windows Server 2019+: Computer Configuration\Administrative Templates\Windows Components\Remote Desktop Services\Remote Desktop Session Host\Temporary folders
  3. Enable the policy Do not use temporary folders per session. to disable the creation of temporary Session ID folders.
  4. Optionally you could also check the policy Restrict Remote Desktop Services users to a single Remote Desktop Services session in the Remote Desktop Session Host\Connections section.

See also