Get IT Solutions

How to do IT
Menu
  • Home
  • SCCM 2012
    • Deploy Packages
    • Troubleshooting errors SCCM 2012
  • Windows
    • Applications Silent Install
    • Windows Tools
    • Windows Error
    • Script
    • Exchange Server
    • Troubleshooting Office
  • Database
    • SQL Server
  • Cybersecurity
  • Other
  • Our Review

3 Method to Delete Temp Files in Windows 7/10 including vbs script

In this post we will explain how to delete temp files windows 7 using three different methods including vbs script and disk-cleanup process. Best solution to free up space on Windows.

  • Delete windows 7 temp files manually step by step.
  • How to Delete temp files windows 7 and 10 auto with script.
  • Delete temp files in windows 7 and 10 from disk-cleanup.

Delete Temp Files Windows 7 and 10.

Can I delete temp files on windows ?

Yes Of course you can delete temp files from windows 7 and 10. I this way you can free up some space form you disk partition.

First of all we are going to explain what windows temp files are. Windows Desktop applications, such as Write, and multiple document interface (MDI) applications, such as Excel, create temporary files to handle necessary user editing. Because a Desktop application cannot have multiple documents open at once, it must immediately create a temporary file that allows you to undo any editing. MDI applications create temporary files only when necessary (for related editing), rather than for every worksheet that is open.

Under normal conditions, these files are closed and deleted by Windows when you quit a Windows session. However, if you quit Windows in an irregular way (for example, restarting the computer or turning it off during an active Windows session) the files are not closed or deleted. Over time, many hundreds of files, created by many programs, can accumulate. When this happens, Windows acts strangely and programs can behave in unusual ways, and can even crash. To avoid this, you should periodically delete temporary files from your computer.

How to Delete temp files on windows 7 and 10 manually step by step.

Step 1: Click on Start button and then choose Run.

Step 2: In the Run window or search box, type the following command:  %temp%

Delete temp files windows 7 and 10

Delete temp files windows 7 and 10

This command, will open the folder that Windows has designated as your Temp folder:

C:\Users\Administrator\AppData\Local\Temp 

Step 3: Select all of the files and folders within the Temp folder that you want to delete (you can use Ctrl+A keyboard shortcut to select all). Delete all the temporary files and folders you have selected, using the Shift + Delete key on your keyboard or delete with the right button of the mouse but don’t forget to empty the recycle bin after doing that.

How to delete temp files on windows 7 and 10

How to delete temp files on windows 7 and 10

Note: You may be asked to confirm that you wish to Delete Multiple Items. You may even have to click Yes on a special Confirm Multiple File Delete window that appears. If you receive a pop-up that says Windows is unable to delete files or Error Deleting File or Folder, it’s probably because they are currently being used. Simply close the program, restart the PC and press Try Again.

Step 4: Repeat all the steps above for the temp folder in the: C:\Windows\temp

The same way you can delete windows 10 temp files. Only graphic interface is different.

Delete temp files windows 7 and 10 auto with script

With this vbs script created by Mohammed Obad you can delete temp files windows 7 and 10 for all User and System  as well as Internet Temp files, with only one click.  Also, you can Deploy with SCCM or configure to GPO. Below you can find the VBS script.

The script works for Windows 10/7/XP.

VBS Script:


'==========================================================================

' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 2009

' NAME:  Delete Temp Files

' AUTHOR: Mohammed Alyafae , 

' DATE  : 9/21/2011

' COMMENT: this script delete all user and system temporary files and folder 

' also delete Internet Temporary files 

'==========================================================================

Option Explicit

Dim objShell

Dim objSysEnv,objUserEnv

Dim strUserTemp

Dim strSysTemp

Dim userProfile,TempInternetFiles

Dim OSType

Set objShell=CreateObject("WScript.Shell")

Set objSysEnv=objShell.Environment("System")

Set objUserEnv=objShell.Environment("User")

strUserTemp= objShell.ExpandEnvironmentStrings(objUserEnv("TEMP"))

strSysTemp= objShell.ExpandEnvironmentStrings(objSysEnv("TEMP"))

userProfile = objShell.ExpandEnvironmentStrings("%userprofile%")

DeleteTemp strUserTemp 'delete user temp files

DeleteTemp strSysTemp  'delete system temp files

 

 'delete Internet Temp files

 'the Internet Temp files path is diffrent according to OS Type

OSType=FindOSType

 

If OSType="Windows 7" Or OSType="Windows Vista" Then

TempInternetFiles=userProfile & "\AppData\Local\Microsoft\Windows\Temporary Internet Files"

ElseIf  OSType="Windows 2003" Or OSType="Windows XP" Then

TempInternetFiles=userProfile & "\Local Settings\Temporary Internet Files"

End If

 

DeleteTemp TempInternetFiles

'this is also to delete Content.IE5 in Internet Temp files

TempInternetFiles=TempInternetFiles & "\Content.IE5"

DeleteTemp TempInternetFiles

 

WScript.Quit

 

Sub DeleteTemp (strTempPath)

On Error Resume Next

 

Dim objFSO

Dim objFolder,objDir

Dim objFile

Dim i

Set objFSO=CreateObject("Scripting.FileSystemObject")

Set objFolder=objFSO.GetFolder(strTempPath)


'delete all files

For Each objFile In objFolder.Files

objFile.delete True

Next


'delete all subfolders

For i=0 To 10

            For Each objDir In objFolder.SubFolders

            objDir.Delete True

            Next

Next

 'clear all objects


Set objFSO=Nothing

Set objFolder=Nothing

Set objDir=Nothing

Set objFile=Nothing

End Sub

 

Function FindOSType

    'Defining Variables

    Dim objWMI, objItem, colItems

    Dim OSVersion, OSName

            Dim ComputerName

            ComputerName="."


    'Get the WMI object and query results

    Set objWMI = GetObject("winmgmts:\\" & ComputerName & "\root\cimv2")

    Set colItems = objWMI.ExecQuery("Select * from Win32_OperatingSystem",,48)

 

    'Get the OS version number (first two) and OS product type (server or desktop) 

    For Each objItem in colItems

        OSVersion = Left(objItem.Version,3)

    Next

    Select Case OSVersion

        Case "6.1"

            OSName = "Windows 7"

        Case "6.0" 

            OSName = "Windows Vista"

        Case "5.2" 

            OSName = "Windows 2003"

        Case "5.1" 

            OSName = "Windows XP"

        Case "5.0" 

            OSName = "Windows 2000"

   End Select

    'Return the OS name

    FindOSType = OSName
    
    'Clear the memory

    Set colItems = Nothing

    Set objWMI = Nothing

End Function 

Just copy the above commands on txt file and save like “deletetempfiles.vbs”

Delete windows 7 temp files from diskcleanup. (The same for Windows 10)

We are going to explain procedures step by step to deleting windows 7 and 10 temp files using dick-cleanup. The below procedures is the same for both Windows operation system, 7 and 10.

Step 1:

In the Start menu, select the All Programs option and choose System Tools from the Accessories menu.

Delete windows 7 and 10 temp files

Delete windows 7 and 10 temp files

Step 2:
From here Select Disk Cleanup. The wizard will identify the files it thinks you can delete, also telling you how much hard-drive space it will free up.

diskcleanup to delete temp files windows

diskcleanup to delete temp files windows

Step 3:
From the list, untick the boxes to ensure just Temporary files and Temporary internet files is selected. Click ‘Clean up system files’. Also you can check other options to delete unused files.

Delete windows 7 temp files

Delete windows 7 temp files

 

If you have any question or error regarding Delete temp files in Window 7 or 10, please feel free to ask!

 

Share
Tweet
Google+
Pinterest
Linkedin
Stumble
Email
Prev Article
Next Article

Related Articles

task scheduler 2147943785
Some common errors which any windows operator would face are …

Windows task scheduler 2147943785 – Failed to start event id 101

windows update KB4048957 issue
The latest Microsoft Windows Update KB4048957 – November 14, 2017 …

Windows Update KB4048957 EPSON Pinters issue – SCCM Script Solution

SQL Server Tips

SQL Server Error 26 and SQL Server Error 40 – How to Fix Them
Error 26 on sql server
SQL Server Error 26 and SQL Server Error 40 appear when you try to connect to SQL Server. We will ...
Read More
How to Reset SQL SA Password from Command Line – Explore Here!
Reset SQL SA Password
This article is about how to reset SQL SA password using cmd. Complete step-by-step method is mentioned to change SQL ...
Read More
Microsoft sql server error 53 – Connection Issue with SQL Server Instance
SQL Server Error 53
Microsoft sql server error 53 is common issue related with connection issue with instances on SQL Server. The reasons of ...
Read More

Search

We are on:

Get FREE SPACE for your PC

delete temp files

3 Method to Delete Temp Files in Windows 7/10 including vbs script

In this post we will explain how to delete temp files windows 7 using three different methods including vbs script ...
Read More

Fastest way to delete hiberfil sys from windows 10/8/7 and XP – CMD

In this article we will explain how to remove or delete hiberfil sys from Windows 10/8/7 and XP . If you does ...
Read More

Get IT Solutions

How to do IT

About Us

Get IT Solutions is a personal blog, which is managed to guide people for various topic.

Second Menu

  • Donate
  • About Us
  • Contact Us
  • Privacy Policy

What Will You Find

Automation is our area of writing where are included scripts, batch and various tips to automate your daily job.
Copyright © 2019 Get IT Solutions
Go to the REVIEW section and read lasted review for different tools and services!
Read Now