Solved

Empty Recycle bin on exit using Group Policy

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

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…
by Batuhan Cetin In this article I will be guiding through the process of removing a failed DC metadata from Active Directory (hereafter, AD) using the ntdsutil tool in a Windows Server 2003 environment. These steps are not necessary in a Win…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

911 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

18 Experts available now in Live!

Get 1:1 Help Now