'DelFiles.vbs
' Sample VBScript to delete files using FileSystemObject
' Author Guy Thomas
http://computerperformance.co.uk/
' Version 2.3 - April 2007
' --------------------------------------------------------'
Option Explicit
Dim objFSO, objFiles, objShell, intCount
Dim strFile, strName, strDirectory, strEnv, strExt
Set objShell = CreateObject("Wscript.Shell")
' ---------------------------------------------------------
' Below is where you edit to delete files in %temp% folder
strEnv = "D:\temp"
' strEnv = objShell.ExpandEnvironmentStrings("%temp%")
intcount = 0
' Create the File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFSO = objFSO.GetFolder(strEnv)
Set objFiles = objFSO.Files
For each strFile in objFiles
On Error Resume Next
strFile.delete
intCount = intCount +1
next
set objFSO = nothing
set strFile = nothing
set objFiles = nothing
'WScript.Echo intCount & " files were deleted"
'WScript.Quit