%TEMP% folder that includes the logon session ID is deleted unexpectedly in Windows Server 2019

Á við um: Windows Server 2019

Symptoms


In Windows Server 2019 that has Desktop Experience installed, the %TEMP% folder that includes the session ID is deleted if you remain logged on to the computer for more than seven days. Therefore, some applications that have to access %TEMP% do not work correctly after that time.

To determine the %TEMP% folder path and verify that the folder was deleted, run the following commands (example output is shown):



You do not experience the issue in the following scenarios:

  • The %TEMP% folder is not included the logon session ID. (For example, C:\Users\<User Account>\AppData\Local\Temp.)
  • %TEMP% folder is not empty.
  • Nobody logs on to the server, or any user session is ended within seven days.

Cause


This behavior is by design.

The %TEMP% folder is deleted by the SilentCleanup task (Cleanmgr.exe) when the logon session exceeds seven days. SilentCleanup is scheduled daily together with Automatic Maintenance.

Workaround


To work around this issue, use one of the following methods.

Method 1 (recommended): Remove the %TEMP% entry from the Folder value

  1. Start Registry Editor. To do this, click Start, click Run, type regedit, and then click OK.
  2. Locate and then click the following registry subkey:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Files
  3. Right-click Folder, and then click Modify.
  4. In the Value data box, delete the %TEMP% entry, and then click OK. For example:

    Value before editing:

    %TEMP%|%WINDIR%\Temp|%WINDIR%\Logs|%WINDIR%\System32\LogFiles

    Value after editing:
    %WINDIR%\Temp|%WINDIR%\Logs|%WINDIR%\System32\LogFiles
  5. Exit Registry Editor.

Note After you make this configuration, you must manually delete the %TEMP% folder to avoid exhausting free space.
 

Method 2: Modify the LastAccess value

Note To follow these steps, install April cumulative update first.

  1. Start Registry Editor. To do this, click Start, click Run, type regedit, and then click OK.
  2. Locate and then click the following registry subkey:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Files
  3. Right-click LastAccess, and then click Modify.
  4. In the Value data box, type a value in days. The range is 7 (default) through 4294967295 (maximum).
  5. Exit Registry Editor.

Note After you make this configuration, the LastAccess value controls the period during which Cleanmgr.exe deletes files in all temporary folders. If the LastAccess value is set too high, this may exhaust free space.