If you wish to empty a users recycle bin upon log off, copy the below code to a notepad and save with the extension .vsb e.g. clean.vbs
Option Explicit
Dim objWshShell, objFSO, objWshNetwork
Dim objRecycleBin, objFolderItems, objItem, strSpecialFolderName
‘Setup main variables and objects
Set objWshShell = WScript.CreateObject(”WScript.Shell”)
Set objFSO = CreateObject(”Scripting.FileSystemObject”)
Set objWshNetwork = WScript.CreateObject(”WScript.Network”)
Set objRecycleBin = GetSpecialFolderObject(”Recycle Bin”)
Set objFolderItems = objRecycleBin.Items()
For Each objItem In objFolderItems
If (objItem.Type = “File Folder”) Then
objFSO.DeleteFolder(objItem.Path)
Else
objFSO.DeleteFile(objItem.Path)
End If
Next
Function GetSpecialFolderObject(NameOfFolder)
Dim objShellApp, i, objSpecialFolder
Set objShellApp = CreateObject(”Shell.Application”)
On Error Resume Next
For i=0 To 40 ’40 is highest value for special folders
Set objSpecialFolder = objShellApp.NameSpace(i)
If (StrComp(objSpecialFolder.Title,NameOfFolder,vbTextCompare)=0) Then
Set GetSpecialFolderObject = objSpecialFolder
Exit For
End If
Next
Err.Clear
End Function
Next, add the script to group policy to run when user logs off.
Please carry out tests before applying on the whole network. This was tested on Windows XP
Thanks
Great script – thankyou
Great script! Thankyou