clean temp files and folders vbs
On Error Resume Next
'Declare variables
Dim fso
Dim oFolder1
Dim oFolder2
Dim oFolder3
Dim oSubFolder1
Dim oSubFolder2
Dim oSubFolder3
Dim colSubfolders1
Dim colSubfolders2
Dim colSubfolders3
Dim oFile
Dim userProfile
Dim Windir
'Set up environment
Set WSHShell = CreateObject("WScript.Shell")
Set fso = createobject("Scripting.FileSystemObject")
userProfile = WSHShell.ExpandEnvironmentStrings("%userprofile%")
Windir = WSHShell.ExpandEnvironmentStrings("%windir%")
'start deleting files
Set oFolder1 = fso.GetFolder(userProfile & "\Local Settings\Temp\")
For Each oFile In oFolder1.files
oFile.Delete True
Next
'Delete folders and subfolders
Set colSubfolders1 = oFolder1.Subfolders
On Error Resume Next
For Each oSubfolder in colSubfolders1
fso.DeleteFolder(oSubFolder), True
Next
Set oFolder2 = fso.GetFolder(userProfile & "\Local Settings\Temporary Internet Files\")
For Each oFile In oFolder2.files
oFile.Delete True
Next
Set colSubfolders2 = oFolder2.SubFolders
For Each oSubfolder in colSubfolders2
fso.DeleteFolder(oSubFolder)
Next
'Set oFolder3 = fso.GetFolder(Windir & "\Temp\")
'For Each oFile In oFolder3.files
'oFile.Delete True
'Next
Set colSubfolders3 = oFolder1.Subfolders
For Each oSubfolder in colSubfolders3
fso.DeleteFolder(oSubFolder)
Next
'Clear memory
Set fso = Nothing
Set oFolder1 = Nothing
Set oFolder2 = Nothing
Set oFolder3 = Nothing
Set oSubFolder1 = Nothing
Set oSubFolder2 = Nothing
Set oSubFolder3 = Nothing
Set colSubfolders1 = Nothing
Set colSubfolders2 = Nothing
Set colSubfolders3 = Nothing
Set oFile = Nothing
Set userProfile = Nothing
Set Windir = Nothing
WScript.Quit