Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Empty Recycle bin on exit using Group Policy

Posted on 2008-06-17
4
Medium Priority
?
9,958 Views
Last Modified: 2011-12-14
Is it possible to empty a Users Recycle bin automatically when they log off using Group Policy?
0
Comment
Question by:RobWasho
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 5

Expert Comment

by:AC_Nova
ID: 21801029
0
 

Author Comment

by:RobWasho
ID: 21801300
Thanks for the quick response.  When I run the script I get an error in Line1 Char:28 Error: Expected end of statement code:800A0401

Any ideas?

0
 
LVL 5

Accepted Solution

by:
AC_Nova earned 1000 total points
ID: 21801367
Download the app, download version 4.71+ of Windows shell.dll.
Check the script for syntax errors.  I have used this before and had no issues.

Hope this helps
0
 
LVL 24

Assisted Solution

by:purplepomegranite
purplepomegranite earned 1000 total points
ID: 21801490
This VBScript empties the recycle bin, and doesn't require any third party utilities.  Simply add it as a logoff script.
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

Open in new window

0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Setting up a Microsoft WSUS update system is free relatively speaking if you have hard disk space and processor capacity.   However, WSUS can be a blessing and a curse. For example, there is nothing worse than approving updates and they just have…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question