Versie 1

For deleting the contents of a directory but not the directory itself:

folderName = "C:\Temp"
 
CONST WaitOnReturn = true
CONST HideWindow = 0
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
 
'Declare the function
Function DeleteContents(dirName)
 
	If objFSO.FolderExists(dirName) Then
 
	Set delcontentsfolder = objFSO.GetFolder(dirName)
 
	'Remove all files in the directory
	For Each File in delcontentsfolder.Files
 
		objFSO.DeleteFile dirName & "\" & File.Name
 
	Next
 
	'Remove all subdirectories
	For Each Directory in delcontentsfolder.SubFolders
 
		objShell.Run "cmd /c rmdir /s /q " & chr(34) & dirName & "\" & Directory.Name & chr(34), HideWindow, WaitOnReturn
 
	Next
 
	'Cleanup
	Set delcontentsfolder = Nothing
 
	End If
 
End Function
 
'Call the function
DeleteContents(foldername)
 
'Cleanup
Set objShell = Nothing
Set objFSO = Nothing