CMTrace Error: Failed to Create Temporary File

I came across an interesting and slightly perplexing error today when trying to open a ConfigMgr Logfile.

I had a remote desktop connection open to a server running a distribution point role, I was opening ConfigMgr logfiles repeatedly with CMTrace without any issues. When suddenly I received the following error:

Failed to create temporary file.


The reason for the error was due to the fact that as part of my troubleshooting of the Distribution Point role I had flushed the Temp directories, CMTrace uses the %Temp% directory to save the temporary file.

Flushing the Temp directories shouldn’t have caused the error, except in a remote desktop session the %Temp% environment variable actually resolves to a subfolder of the user profiles normal Temp directory.

On a normal user profile %Temp% resolves to something like:

On a remote desktop session %Temp% resolves to something like:
C:\Users\User\AppData\Local\Temp\2 (The number varies between sessions)

To resolve the error you can do one of the following:

  1. Create the numbered folder in the Temp directory
  2. Log Off and Log back on to the remote desktop session, the folder is automatically created at logon

Leave a Reply

Your email address will not be published. Required fields are marked *