Solved

Empty Recycle bin on exit using Group Policy

Posted on 2008-06-17
4
9,455 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
  • 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 250 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 250 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Preface Having the need * to contact many different companies with different infrastructures * do remote maintenance in their network required us to implement a more flexible routing solution. As RAS, PPTP, L2TP and VPN Client connections are no…
So you have two Windows Servers and you have a directory/folder/files on one that you'd like to mirror to the other?  You don't really want to deal with DFS or a 3rd party solution like Doubletake. You can use Robocopy from the Windows Server 200…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now