Fix: Error writing a temporary file, Make sure your temp folder is valid

Error writing a temporary file, Make sure your temp folder is valid indicates that there is a problem with the folder Windows uses to store temporary files. This error can result from several reasons, such as the temporary folder being set in a different location, being deleted, or the user account in Windows lacking permissions.

"Error writing temporary file, Make sure your temp folder is valid"
“Error writing a temporary file, Make sure your temp folder is valid”

There are several fixes mentioned below. Let’s dive into the solutions and fix this error.

1. Run the installer as an admin.

If the installer does not have administrator permissions, it will not be able to access the temporary files folder, resulting in the following error. To fix this issue, it is recommended to run the installer as an administrator. Follow these steps:

  1. Right-click on the installer file.
  2. Now, left-click on “Run as Administrator.
    Run as administrator
    Run as administrator
  3. A dialogue box will appear with Yes and No options; click Yes.
    Run as administrator window
    Run as administrator window

If you are on a user account, please refer to the administrator of your computer to help you resolve this issue.

2.  Clean temporary files.

If there is no space left on the disk where the temporary files folder is located, you will encounter the following error. In this case, it is recommended to clean up your temporary files folder to make space for new temporary files. Follow these steps to clear your temporary files folder:

  1. Press the Windows key + R to launch the Run dialog.
  2. Type %temp% and hit Enter.
    Running temp command in run
    Running temp command in run
  3. Click Ctrl + A to select all items.
  4. Then, click Delete or press Ctrl+Delete to delete all files at once.

It’s okay if some files are unable to be deleted; it happens when those temporary files are being used by a process. They will be deleted eventually when the program is done using them.

3. Restart the Windows Installer service.

The Installer service assists with the installation and removal of software in Windows. This service may occasionally experience problems or stop functioning, which can interfere with the installation or removal of programs. Setting the parameters of this service back to default may fix it, enabling you to install the desired program.

  1. Open the Run dialog by pressing Win + R on the keyboard.
  2. Type “services.msc” in the dialog box.
    Restarting windows installer
    Restarting windows installer
  3. In the services tab, Scroll down and find “Windows Installer”

    Restarting windows installer
    Restarting windows installer
  4. Right-Click on Windows Installer and select the “Restart” button from the context menu.
    Restarting windows installer
    Restarting windows installer

Check to see whether the error is fixed.

4. Change the path of the Temp folder.

Some locations in Windows have very restricted access; only certain services and programs that Windows allows can access these locations, while an average user account cannot. In this case, we will define a new temporary files location for all the temporary files, allowing Windows to direct the program installer to this new location, which is much less restrictive than the normal temporary files location. Please follow these steps:

  1. Locate the C Drive.
  2. Now, Right-Click and create a folder.
    Creating folder in C Drive
    Creating folder in C Drive
  3. Press Win + I to launch the Settings tab and Navigate to System.

    Opening Windows Settings
    Opening Windows Settings
  4. Then, go to ‘About‘.
  5. Click on Advanced System Settings, which is under the device’s specifications.
    Going to Advanced Settings
    Going to Advanced Settings
  6. Then, click on Environmental Variables.

    Opening Environment Variables
    Opening Environment Variables
  7. Double-click on the TMP variable.
    Clicking TMP variable
    Clicking TMP variable
  8. The existing location or variable value would be
    %USERPROFILE%\AppData\Local\Temp
  9. Change this variable to the location where you created the folder; in this case, that would be:
    C:\Temp

    Click on “OK.

    Changing the Variable value
    Changing the Variable value
  10. Now, close all the windows and restart your computer.

Check to see if the issue persists.

5. Disable Windows Defender.

Windows Defender can sometimes block the installer from accessing the temporary files folder. This is done in order to protect your computer and prevent unnecessary access to vulnerable files in Windows. However, if you trust the installer of the program, you can temporarily disable Windows Defender to allow the installer to install the program. Follow these steps:

  1. IIn the Windows Search bar, enter “Windows Security
    Disabling windows defender
    Disabling windows defender
  2. Click on Virus & Threat Protection from the sidebar menu.
    Disabling windows defender
    Disabling windows defender
  3. Now, select “Manage Settings” under this section.
    Disabling windows defender
    Disabling windows defender
  4. Then, go to Toggle Off Real-time Protection.
    Disabling windows defender
    Disabling windows defender
  5. Restart your computer.

Now, check your installer by running it in administrative mode. Your error will be gone, and you can install any file you want while running it on your computer.

ABOUT THE AUTHOR

Kevin Arrows


Kevin Arrows is a highly experienced and knowledgeable technology specialist with over a decade of industry experience. He holds a Microsoft Certified Technology Specialist (MCTS) certification and has a deep passion for staying up-to-date on the latest tech developments. Kevin has written extensively on a wide range of tech-related topics, showcasing his expertise and knowledge in areas such as software development, cybersecurity, and cloud computing. His contributions to the tech field have been widely recognized and respected by his peers, and he is highly regarded for his ability to explain complex technical concepts in a clear and concise manner.